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

Create an application that showcases libp2p universal connectivity #1

Closed
p-shahi opened this issue Mar 6, 2023 · 10 comments
Closed
Assignees

Comments

@p-shahi
Copy link
Member

p-shahi commented Mar 6, 2023

Motivation

libp2p supports a wide range of transports that enable libp2p nodes to run as server nodes (on personal PCs or datacenters) or as browser nodes (within the browser).
These libp2p nodes (executing across different runtime environments) can interoperate with one another.
The goal of this project is to demonstrate the interoperability and universal connectivity that libp2p provides.

Goal

We create a sample chat application runs on a diverse libp2p network topology.
This network topology will showcase the different ways nodes can connect to one another. It must contain:

  • Three browser nodes B1, B2, and B3 (using js-libp2p)
  • Three server nodes S1, S2, and S3 (S1 and S2 running go-libp2p and S3 running rust-libp2p)

The nodes should form their connections like so:

B1 ← WebRTC W3C → B2 ← WebRTC W3C → B3
↑ ...................................↑ .................................↑
WebRTC B2S.......WebTransport........WebRTC B2S
↓ ...................................↓ .................................↓
S1←...........TCP...........→S2←...........QUIC.......→S3

This showcases:

  • WebRTC W3C: browser to browser connectivity)
  • WebRTC browser to server: a browser node (js-libp2p) connecting to a server node (both go and rust libp2p)
  • QUIC: interoperability between two server nodes (go and rust libp2p)
  • TCP: last but not least, connecting two server nodes

Note: Other necessary entities in the network like libp2p relay servers or public STUN servers are not shown in the above topology.

In this version of the example, we omit the WebSocket transport but it can be extended in the future to include it.

Outcome

The outcome of this project should be tutorial that walks through the creation of this sample chat app and teaches users how to run libp2p nodes and make use of these new connectivity options.
We can approach the outcome in a piecemeal approach.
The MVP can be to create a tutorial of just the small network of browser nodes and showcase the WebRTC transport.
The second phase can be to incorporate the server nodes (this can also be done piecemeal, for example we could introduce the server nodes one at a time and make the last leg of the tutorial to connect the server nodes with one another.)

Along with a written example, it'd be great to have a video or a presentation that we can showcase to users (and to an audience at IPFS Thing.)

Something this is also desirable but may be out of scope is an interactive webapp that can demonstrate the connectivity options and enable a user to deploy the local network described above with just a few clicks.

Depends on WebRTC W3C in js-libp2p: libp2p/js-libp2p-webrtc#90 and WebRTC browser-to-server in go-libp2p: libp2p/go-libp2p#1999

@2color
Copy link
Collaborator

2color commented Mar 7, 2023

Thanks for the writeup @p-shahi.

To make this project more digestible, I've started tackling some of the subproblems for this to work.

The first is peer routing, i.e., establishing connectivity from using PeerIDs like 12D3KooWRBy97UB99e3J6hiPesre1MZeuNQvfan4gBziswrRJsNK with js-libp2p (rather than hard coding unstable multiaddresses which can change when IPs change or when certificate hashes change).

I'm first testing this out with TCP from Node for easier testing.js: https://github.com/2color/js-libp2p-transports-example

Would love your support on getting this working. I should be able to get a WebTransport example ready this week

@p-shahi
Copy link
Member Author

p-shahi commented Mar 8, 2023

@2color can you create an issue in the js-libp2p repo so that we can diagnose/debug the peer routing there?

@2color
Copy link
Collaborator

2color commented Mar 15, 2023

Following a discussion with @TheDiscordian, we're planning on tackling this as follows:

  • GossipSub-based chat app with a single topic for all peers

JS Web App

  • The JS/TS browser app will implement the UI and connect to other peers over WSS/WebTransport/WebRTC

@2color will lead the work on this. Currently in https://github.com/2color/js-libp2p-transports-example/ but will move to this repo

Go Daemon

  • build a lightweight Go libp2p chat daemon
  • Use WebTransport / WebRTC / QUIC / TCP
  • No added encryption
  • Single topic
  • Showcase connectivity
    • Go <-> Browser (WebTransport / WebRTC)
    • Go <-> Rust (QUIC / TCP)
  • Initial support for reading chat messages from the topic
  • Bonus: allow sending messages from STDIN

@TheDiscordian will lead the work on this

Rust daemon

  • Similar to the Go daemon

Currently, we don't have the capacity to do the development of the Rust daemon. So we'd need support for that part.


All the code will live in this repo, i.e. a big mono-repo for all language implementations.

@p-shahi
Copy link
Member Author

p-shahi commented Mar 15, 2023

Thanks for the plan @TheDiscordian and @2color!

One comment on the "No added encryption" - Noise for TCP connections should be added imo.

@2color
Copy link
Collaborator

2color commented Mar 15, 2023

Sorry, I should have been more specific. Encryption over the wire, i.e. transport encryption, will definitely be implemented.

@p-shahi
Copy link
Member Author

p-shahi commented Mar 15, 2023

Some resources here:

@mxinden
Copy link
Member

mxinden commented Mar 16, 2023

Rust daemon

* Similar to the Go daemon

Currently, we don't have the capacity to do the development of the Rust daemon. So we'd need support for that part.

A Rust daemon would be easy to add by combining https://github.com/mxinden/rust-libp2p-server/ with the WebRTC transport instantiation and a call to Swarm::listen_on with a /webrtc address https://github.com/libp2p/rust-libp2p/blob/14292c4758eafd6ff4414cde8b3a9f97292f659b/interop-tests/src/bin/ping.rs#L71-L76

@2color
Copy link
Collaborator

2color commented Mar 17, 2023

I just discovered that we have a pubsub example that could be adapted to this project: https://github.com/libp2p/go-libp2p/tree/master/examples/pubsub/chat

Since we're under a time crunch, I'd suggest we make use of it @TheDiscordian

To adapt it, we'd need to add WebTransport and WebRTC (once the PR for that is merged)

@2color
Copy link
Collaborator

2color commented Mar 17, 2023

@mxinden We're probably going to need your help with that.

I'm not too familiar with async rust (rust-libp2p-server uses async io and the other link is with Tokio) and the links you sent aren't sufficient for me to move on this without any extra help.

@2color
Copy link
Collaborator

2color commented Apr 29, 2024

Closing this as most things have already been implemented.

@2color 2color closed this as completed Apr 29, 2024
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

No branches or pull requests

3 participants