Giter Site home page Giter Site logo

libp2p / universal-connectivity Goto Github PK

View Code? Open in Web Editor NEW
69.0 13.0 30.0 17.05 MB

Realtime decentralised chat with libp2p showing ubiquitous peer-to-peer connectivity between multiple programming languages (Go, Rust, TypeScript) and runtimes (Web, native binary) using QUIC, WebRTC and WebTransport

Home Page: https://universal-connectivity.vercel.app

License: Other

JavaScript 0.23% TypeScript 75.47% CSS 0.03% Go 12.36% Dockerfile 0.68% Rust 11.23%
go libp2p networking p2p peer-to-peer rust webrtc webtransport

universal-connectivity's Introduction

Universal Connectivity

Realtime highly decentralised chat app.

libp2p topology

Showcasing libp2p's superpowers in establishing ubiquitous peer-to-peer connectivity in modern programming languages (Go, Rust, TypeScript) and runtimes (Web, native binary).

On top of this strong foundation, it layers a GossipSub: A Secure PubSub Protocol for Unstructured Decentralised P2P Overlays. By analogy, an event broker with distributed brokering, or a distributed PubSub protocol.

This is the gossip event protocol that powers Filecoin and Post-Merge Ethereum.

Some of the cool and cutting-edge transport protocols used by this app are:

  • WebTransport
  • WebRTC
  • QUIC
  • TCP

Packages

Packge Description WebTransport WebRTC QUIC TCP
js-peer Next.js based browser UI of the chat app
go-peer Chat peer implemented in Go
rust-peer Chat peer implemented in Rust

✅ - Protocol supported ❌ - Protocol not supported

  • Uses the GossipSub PubSub protocol for decentralised messaging

Connecting to a peer

There are two ways to connect to a peer:

  • With a PeerID using peer routing (adds a step to resolve the multiaddr for the PeerID), using the IPFS/Libp2p DHT, e.g. 12D3KooWLMySi3eEWscUnKmMCYRSXL3obYJ4KNimpShJK6shUy2M
  • With a multiaddr directly (skips the peer routing step), e.g. /ip4/127.0.0.1/udp/64434/webrtc/certhash/uEiA_tkndZQWf7jyFqgCiwH_CqsS7FTWFTb6Px8MPxxT9gQ/p2p/12D3KooWLMySi3eEWscUnKmMCYRSXL3obYJ4KNimpShJK6shUy2M

8-minute project setup & demo video git

Using a multiaddr

Load the UI, and enter the multiaddr into the UI. Ensure that it includes the peerID, e.g./ip4/192.168.178.21/udp/61838/quic-v1/webtransport/certhash/uEiCQCALYac4V3LJ2ourLdauXOswIXpIuJ_JNT-8Wavmxyw/certhash/uEiCdYghq5FlXGkVONQXT07CteA16BDyMPI23-0GjA9Ej_w/p2p/12D3KooWF7ovRNBKPxERf6GtUbFdiqJsQviKUb7Z8a2Uuuo6MrDX

Getting started: JS

1. Install dependencies

Run npm install:

cd js-peer
npm i

2. Start Next.js dev server

Start the dev server:

npm run dev

Getting started: Rust

cd rust-peer
cargo run

This will automatically connect you to the bootstrap node running on fly.io.

To explore more advanced configurations if you e.g. want to set up our own network, try:

cargo run -- --help

Getting started: Go

cd go-peer
go run .

universal-connectivity's People

Contributors

2color avatar achingbrain avatar dependabot[bot] avatar douganderson444 avatar dozyio avatar galargh avatar jochasinga avatar libp2p-mgmt-read-write[bot] avatar maceip avatar maschad avatar mxinden avatar p-shahi avatar randymcmillan avatar thediscordian avatar thomaseizinger avatar web-flow avatar youngjoon-lee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

universal-connectivity's Issues

JS: update stream mgmt in the new way refactored

Reference: #76 (comment)

I'm informed that js-libp2p has refactored their way to handle streams. According to the way, JS code in this repo should be updated.

Currently, the main branch doesn't have the related code, but that will be added once we merge #76.

I'd like to assign this issue to myself.

Compiling rust-peer to wasm

Would be cool if rust-peer could support compiling to wasm directly with wasm-pack (it currently fails) and exporting it as a node package or using it in the browser

Create an application that showcases libp2p universal connectivity

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

browser-to-browser connectivity with webRTC and pubsub (gossipsub)

Dear all,

I have been working on an example to showcase browser to browser connectivity. The goal is to subscribe to a topic and display the messages published by other peers on that topic.

Also, I don't want to host a relay server myself, but instead use a public relay server hosted by someone else for now.
For this, I built a frontend that helps to connect two a publisher/server and a subscriber/client:

Screenshot 2023-06-27 at 15 06 20 Screenshot 2023-06-27 at 15 06 34

To reproduce, just clone the repo, then cd experiments/ipfs, yarn and yarn dev.

As you can see in the above screenshots, I test this in two independent incognito browser windows, one acting as a server and one as a client.

Now I have two problems:

  • The peers only sometimes connect to each other and the connection is not very stable
  • Even when the peers connect, the client peer does not display the message published by the server

I guess it has something to do with the libp2p configuration or my other code dealing with connectivity, but I can't figure out what the problem is... Can someone here help me? I think it would be great for others as well to know how to do this :)

Set sane limits for the browser node

The current limits set in libp2p.ts were set at their current values in order to get the app working for the IPFS Thing demo.
We need to configure saner limits instead of these arbitrarily high values.

Limits to address

    dht: kadDHT({
      protocolPrefix: "/universal-connectivity",
      maxInboundStreams: 5000,
      maxOutboundStreams: 5000,
      clientMode: true
    }),

https://github.com/libp2p/universal-connectivity/blob/main/packages/frontend/src/lib/libp2p.ts#L32

    identify: {
      // these are set because we were seeing a lot of identify and identify push
      // stream limits being hit
      maxPushOutgoingStreams: 1000,
      maxPushIncomingStreams: 1000,
      maxInboundStreams: 1000,
      maxOutboundStreams: 1000,
    },

https://github.com/libp2p/universal-connectivity/blob/main/packages/frontend/src/lib/libp2p.ts#L70

Documented more in https://hackmd.io/K_MkPfjOTyaLfLME4b25aw

Display browser nodes listen addresses in UI

We currently only display the peer ID, but we should also display a browser nodes listen addresses (i.e. it's webrtc-direct, websocket, relayed multiaddr)
This will be informative and also aid in debugging (currently, we have to grab the listen addresses from the console log)

Render connected peers in the chat UI

Background

As a user, I want to know who else is in the chatroom.

We should render a list of all the other peers in the gossipsub channel.

https://github.com/feross/p2p-graph is a cool way to explore rendering the graph visually.

Details

  • Note that this chat peers may be different to the connected peers. Indeed, many of the peers you will connect to are gonna be on this topic but you may be also connected to bootstrap nodes which aren't listening on the topic and shouldn't be rendered.

connectivity degradation

In the latestmain, I am no longer able to establish browser to server or browser to browser connectivity

Create a tutorial

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

Go build error

Hi, I got this error when trying to run the go code. Here's what happened:

# install go
> $ sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz   
...                                                        
> $ go version         
go version go1.21.1 linux/amd64
> $ cd go-peer           
> $ ls                          
chat-example.gif  chatroom.go  Dockerfile  flag.go  go.mod  go.sum  identity.go  main.go  README.md  ui.go
> $ go run .                                                                                                                              go: downloading github.com/multiformats/go-multiaddr v0.9.0
go: downloading github.com/gdamore/tcell/v2 v2.6.0
go: downloading github.com/libp2p/go-libp2p-kad-dht v0.23.0
go: downloading github.com/rivo/tview v0.0.0-20230406072732-e22ce9588bb4
go: downloading github.com/libp2p/go-libp2p-pubsub v0.9.3
go: downloading github.com/multiformats/go-varint v0.0.7
go: downloading github.com/ipfs/go-cid v0.4.1
go: downloading github.com/multiformats/go-multibase v0.2.0
go: downloading github.com/multiformats/go-multihash v0.2.1
go: downloading github.com/multiformats/go-base36 v0.2.0
go: downloading github.com/multiformats/go-base32 v0.1.0
go: downloading github.com/mr-tron/base58 v1.2.0
go: downloading github.com/libp2p/go-buffer-pool v0.1.0
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading github.com/ipfs/go-log/v2 v2.5.1
go: downloading github.com/libp2p/go-msgio v0.3.0
go: downloading github.com/ipfs/go-log v1.0.5
go: downloading github.com/gdamore/encoding v1.0.0
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
go: downloading github.com/mattn/go-runewidth v0.0.14
go: downloading golang.org/x/sys v0.7.0
go: downloading golang.org/x/term v0.7.0
go: downloading golang.org/x/text v0.9.0
go: downloading github.com/rivo/uniseg v0.4.4
go: downloading github.com/mattn/go-isatty v0.0.18
go: downloading go.uber.org/multierr v1.11.0
go: downloading go.uber.org/zap v1.24.0
go: downloading github.com/minio/sha256-simd v1.0.0
go: downloading github.com/spaolacci/murmur3 v1.1.0
go: downloading golang.org/x/crypto v0.8.0
go: downloading lukechampine.com/blake3 v1.1.7
go: downloading github.com/klauspost/cpuid/v2 v2.2.4
go: downloading go.uber.org/atomic v1.10.0
go: downloading github.com/google/uuid v1.3.0
go: downloading github.com/google/gopacket v1.1.19
go: downloading github.com/ipfs/boxo v0.8.0
go: downloading github.com/ipfs/go-datastore v0.6.0
go: downloading github.com/jbenet/goprocess v0.1.4
go: downloading github.com/libp2p/go-libp2p-kbucket v0.5.0
go: downloading github.com/libp2p/go-libp2p-record v0.2.0
go: downloading github.com/libp2p/go-netroute v0.2.1
go: downloading github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1
go: downloading go.opencensus.io v0.24.0
go: downloading go.opentelemetry.io/otel v1.14.0
go: downloading go.opentelemetry.io/otel/trace v1.14.0
go: downloading gonum.org/v1/gonum v0.12.0
go: downloading github.com/opentracing/opentracing-go v1.2.0
go: downloading github.com/hashicorp/golang-lru v0.5.4
go: downloading github.com/hashicorp/go-multierror v1.1.1
go: downloading github.com/hashicorp/errwrap v1.1.0
go: downloading github.com/go-logr/logr v1.2.4
go: downloading github.com/go-logr/stdr v1.2.2
go: downloading github.com/libp2p/go-libp2p-asn-util v0.3.0
go: downloading github.com/ipfs/go-ipfs-util v0.0.2
go: downloading github.com/libp2p/go-cidranger v1.1.0
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/ipld/go-ipld-prime v0.20.0
go: downloading github.com/multiformats/go-multicodec v0.8.1
go: downloading github.com/polydawn/refmt v0.89.0
main.go:14:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer
../../go/pkg/mod/github.com/libp2p/[email protected]/pubkey.go:8:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/crypto (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer
../../go/pkg/mod/github.com/libp2p/[email protected]/pubkey.go:9:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/peer (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer
../../go/pkg/mod/github.com/ipfs/[email protected]/ipns/record.go:14:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/peerstore (imported by github.com/libp2p/go-libp2p-kad-dht); to add:
	go get github.com/libp2p/[email protected]
../../go/pkg/mod/github.com/libp2p/[email protected]/providers/providers_manager.go:20:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/p2p/host/peerstore (imported by github.com/libp2p/go-libp2p-kad-dht); to add:
	go get github.com/libp2p/[email protected]
../../go/pkg/mod/github.com/libp2p/[email protected]/internal/config/config.go:13:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/host (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer
../../go/pkg/mod/github.com/libp2p/[email protected]/internal/config/config.go:15:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/protocol (imported by github.com/libp2p/go-libp2p-kad-dht); to add:
	go get github.com/libp2p/[email protected]
../../go/pkg/mod/github.com/libp2p/[email protected]/internal/config/quorum.go:3:8: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/routing (imported by github.com/libp2p/go-libp2p-kad-dht); to add:
	go get github.com/libp2p/[email protected]
../../go/pkg/mod/github.com/libp2p/[email protected]/pb/message.go:4:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/network (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer
../../go/pkg/mod/github.com/libp2p/[email protected]/subscriber_notifee.go:7:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/event (imported by github.com/libp2p/go-libp2p-kad-dht); to add:
	go get github.com/libp2p/[email protected]
../../go/pkg/mod/github.com/libp2p/[email protected]/subscriber_notifee.go:10:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/p2p/host/eventbus (imported by github.com/libp2p/go-libp2p-kad-dht); to add:
	go get github.com/libp2p/[email protected]
../../go/pkg/mod/github.com/libp2p/[email protected]/tag_tracer.go:8:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/connmgr (imported by github.com/libp2p/go-libp2p-pubsub); to add:
	go get github.com/libp2p/[email protected]
../../go/pkg/mod/github.com/libp2p/[email protected]/discovery.go:8:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/discovery (imported by github.com/libp2p/go-libp2p-pubsub); to add:
	go get github.com/libp2p/[email protected]
../../go/pkg/mod/github.com/libp2p/[email protected]/gossipsub.go:17:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/core/record (imported by github.com/libp2p/go-libp2p-pubsub); to add:
	go get github.com/libp2p/[email protected]
../../go/pkg/mod/github.com/libp2p/[email protected]/discovery.go:11:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/p2p/discovery/backoff (imported by github.com/libp2p/go-libp2p-pubsub); to add:
	go get github.com/libp2p/[email protected]
main.go:20:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/p2p/discovery/mdns (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer
main.go:21:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/p2p/discovery/routing (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer
main.go:22:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/p2p/discovery/util (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer
main.go:23:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/p2p/transport/quic (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer
main.go:24:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/p2p/transport/websocket (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer
main.go:25:2: missing go.sum entry for module providing package github.com/libp2p/go-libp2p/p2p/transport/webtransport (imported by github.com/libp2p/universal-connectivity/go-peer); to add:
	go get github.com/libp2p/universal-connectivity/go-peer

Support sending files

Hi all,

Thank you for making this repo. It’s super helpful to understand how to configure nodes for each programming languages and to see the current state of libp2p connectivity.

If I’m allowed, I would like to try to implement the file-sharing feature using the request-response protocol. The file-sharing example is already presented in the rust-libp2p repo, but it would be meaningful to implement it in this repo using multiple programming languages.

I’m thinking about the following scenario.

  • Browser A clicks a send-file button next to the message textbox. Then, a file browser is opened. The user selects a file. The browser holds the file in memory and provide the file using Kademlia (start-providing). Plus, Browser A publishes a special message FileAd(name) via gossipsub.
  • Other browser peers, which receive the FileAd(name) message, execute the Kademlia get-provider operation. After getting the provider information, it sends a file request to Browser A by its relay address. Until the file is delivered, web UI just shows a temporary message box: Receiving a file.
  • Finally, Browser A sends a file response back to the file requester. Then, the web UI of the file requester displays a clickable file name in the message box, so that the user can download the file to their local.

I’m not sure if this scenario will work, but I think it’s worth trying, if I can have a chance to do it.

Remaining tasks for mvp of app

remaining

  • #56
  • #57
  • add webtransport addr to default bootstrappers
  • adding Max's pubkey to ec2

done

  • fix bootstrap issue - when bootstrapping onto the relay node (instead of directly dialing), we do not discover other browser peers via KadDHT
  • generate static TLS certificate for rust peer #19
  • deploy new rust peer to EC2 #19
  • #23
  • remove Peer ID to connect to and multiaddr to connect to - @maschad
  • persist chat messages on chat tab (when switching between chat tab and connecting to peer tab, the chat messages are lost) - @maschad
  • have a unique identifier (last few characters of peer)? #39 -@maschad
  • set up max connection limit in js-libp2p-gossipsub (limit the size of meshes) - @maschad
  • do something about Juan/tom/alex on the burger button on mobile - @maschad
  • disable autonat in the browser #45
  • investigate why webrtc connections aren't being established (or shown) on safari mobile
  • #43

defer

  • remove lan from kademlia protocol name
  • when protocol names get appended in the array, it creates another entry (perhaps in the peer store) - will be addressed by a UI fix @maschad
  • Get it working on firefox libp2p/js-libp2p-webrtc#109
  • close rust relay connection after 1 minute - @maschad
  • #21

Create a CODEOWNERS file

We should create a CODEOWNERS file for the individual directories of the different languages. That way, the various teams will automatically be requested a review for when dependabot opens a new PR.

Browser to browser connectivity not established with IPv6

When using IPv6 addresses by default, I that observe two browser nodes A and B are both able to establish a webrtc-direct connection to the relay node but neither a relayed connection nor a subsequent webrtc connection to one another.
This functionality works when using IPv4 with no other changes.

Render indenticons for peers in chat

Background

Once multiple peers join a chat room, the UI should help you distinguish who the messages are coming from.

Identicons are a common way to do create unique visual identifiers.

Details

Render an identicon next to each message in the chat UI based on the peer ID.

Note that this requires that all messages are signed; otherwise, the originating peer ID is not included in the message.

Go Node Tasks

Noting these down to help track them:

  • Should be able to connect to a list of multiaddrs via cli flag
  • QUIC / TCP / WebSocket transports
  • public EC2 ip address via a cli flag using Address Factory

bug: Messages are not rendered in the frontend when sent via the go-peer

@2color :

I did some testing of the go-peer.
There’s a bug that I think we saw with Rust where sometimes messages aren’t rendered in the frontend even though there’s a log in the frontend saying RPC gossipsub:
https://share.descript.com/view/rXxz0yCOHjF

@p-shahi :

This issue occurred with the rust peer since it was sending each message with the same sequence number. Js-libp2p-gossipsub’s default behavior was to use the sequence number to deduplicate messages and since the numbers were the same it was discarding some messages received. Adding the message ID function in js-libp2p-gossipsub fixed it.
I don’t think it’s the same issue since the same message ID function will be applied to all incoming messages regardless of go or rust peer. Can try to dig into this today.

Improvements to the Go daemon

From our testing, we can confirm that the Go chat daemon can exchange messages with the frontend.

To make it more suitable for deployment and cleaner, we need to make the following changes:

  • Enable a persistent PeerID, either via an env var or serialised as a file. This is to ensure that the PeerId doesn't change on every reload. We need this because we will hard code at least one PeerID into the frontend to make sure "it just works" on load.
  • Instead of logging every system logs into the chat window, create a split view for the system logs
  • Publish messages directly without json

feat: some chat UX improvement ideas

  • it would be cool if last X-time/count chat history was stored

  • would be cool to run js side in service-worker/web-worker so we could get messages while offline (until browser kills it anyway)

  • emoji icon is currently broken in brave + firefox (I assumed clicking would allow me to choose an emoji, but I get no response or visual feedback)

add new gossipsub topic to publish listen address messages

Browser A connects to relay node
Browser A learns it's relayed multiaddress
Publishes the relayed multiaddr to the new topic
Browser B boots up subscribes to the new topic, connects to relay node
It receives A's relayed multiaddr through the new topic
B then dials A using the relayed multiaddr and establishes a webrtc connection

In React, Uncaught Error: Cannot find module 'interface-datastore/key'

In React, Uncaught Error: Cannot find module 'interface-datastore/key'

Package.json

{
  "name": "testapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@orbitdb/core": "^1.0.1",
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "@types/interface-datastore": "^3.0.0",
    "@types/jest": "^27.5.2",
    "@types/node": "^16.18.65",
    "@types/react": "^18.2.38",
    "@types/react-dom": "^18.2.17",
    "helia": "^2.1.0",
    "it-drain": "^3.0.5",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "typescript": "^4.9.5",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "packageManager": "[email protected]",
  "devDependencies": {
    "@types/events": "^3"
  }
}

App.tsx

import React, { useEffect } from "react";
// import logo from './logo.svg';
import "./App.css";
import { createHelia } from "helia";
import { createOrbitDB } from "@orbitdb/core";

function App() {
  useEffect(() => {
    (async function () {
      const ipfs = await createHelia();
      const orbitdb = await createOrbitDB({ ipfs });
      const db = await orbitdb.open("hello");
      const address = db.address;
      console.log("address", address);
    })();
  }, []);
  
  return (
    <div className="App">
      <header className="App-header">
        {/* <img src={logo} className="App-logo" alt="logo" /> */}
        <p>
          Edit <code>src/App.tsx</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;

Get deployment pipeline set up

To have a dedicated infrastructure for the connectivity project, we will have the rust peer (& relay) and go peer run as long lived instances on EC2
We need a pipeline that automates deploying new revisions to those EC2 instances

Enable dependabot

To not miss out on new versions of libraries, we should enable dependabot.

Update Kademlia `NetworkBehaviour` in Rust Peer

Note that adding the Kademlia NetworkBehaviour in itself is not quite enough. You would (a) need to execute the bootstrap method regularly and (b) actively add peers (like you do, commented out, for the bootstrap nodes).

You can find an example here:

(a) https://github.com/mxinden/rust-libp2p-server/blob/4d887c720bf25ad282c58d8f7d9773715a2b5c70/src/main.rs#L162-L169

(b) https://github.com/mxinden/rust-libp2p-server/blob/4d887c720bf25ad282c58d8f7d9773715a2b5c70/src/main.rs#L172-L199

The latter will be automated once we have libp2p/rust-libp2p#2680.

Originally posted by @mxinden in #17 (comment)

Help js browser peers discover each other out of the box

Background

When I initially created this project, I aimed to have it simply work when loaded in the browser for demo purposes. I wanted to show how easy libp2p makes it for different runtimes and languages to connect to each other — even when behind NAT.

I wanted to be able to just share the URL as part of a talk/demo, and for browsers to just establish connectivity with each other.

Moreover, it expands the scope of this demo app to include a critical part of any libp2p app, namely peer discovery/routing.

Current challenges

  • There's no existing protocol or suggestions regarding how browsers should discover each other's webrtc multiaddrs.

  • The example relies on hardcoded ephemeral multiaddrs — this is actually an antipattern because the multiaddrs are invalid after a the certificates are rotated (~ 2 weeks).

Ideal case

  • We have both Rust and Go peers deployed. #91 should solve the Rust node
  • The js peer has the PeerIds of the Rust and Go peers, hardcoded
  • The js peer can do peer routing to discover the latest multiaddrs of the Rust/Go peers

Open questions

  • Which peer routing/discovery approach should be used for this? DHT with the public bootstrap nodes or Rendezvous?

Upgrade Bootstrap nodes IP version?

export const WEBRTC_BOOTSTRAP_NODE = "/ip4/18.195.246.16/udp/9090/webrtc-direct/certhash/uEiA8EDMfADmULSe2Bm1vVDSmN2RQPvY5MXkEZVOSyD1y2w/p2p/12D3KooWSmtsbL2ukwVwf8gDoTYZHnCd7sVNNVdMnCa4MkWjLujm"
export const WEBTRANSPORT_BOOTSTRAP_NODE = "/ip4/3.125.128.80/udp/9095/quic-v1/webtransport/certhash/uEiAGIlVdiajNz0k1RHjrxlNXN5bb7W4dLPvMJYUrGJ9ZUQ/certhash/uEiDYZsZoO8vuTKlPhxvVR5SFwOkbXfjlsmTLUHNlnG24bg/p2p/12D3KooWEymoJRHaxizLrrKgJ9MhEYpG85fQ7HReRMJuEMLqmNMg"

Did we want to upgrade these to IPv6 as well?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.