berty / weshnet

Async Mesh Network Protocol for Extreme Communication -- Innovative, Resilient, and Decentralized
https://wesh.network
Other
151 stars 27 forks source link

Can this be used with Helia / browsers? #55

Closed Erudition closed 1 year ago

Erudition commented 1 year ago

Asking a question, not reporting a bug

Is there an existing issue for this?

Question

I'm currently powering my upcoming app with OrbitDb, which as far as I know is still the underlying technology for wesh. However it works in the browser, with js-ipfs and someday Helia. Better IPFS nodes exist for the native applications, such as on Desktop or Android (orbitdb for android can be called directly), but I'd like to also communicate with the webapp if needed.

Context

I can do gRPC in the browser, no problem, but I'm suspicious that the weshnet stack won't work there. Perhaps webassembly could work (with WebBluetooth or limited transports) for the Go app. A SharedWorker would be ideal!

Anyway, hoping to upgrade my OrbitDb usage to weshnet soon...

jefft0 commented 1 year ago

Hello @Erudition . A while ago, we tried compiling the Go code of weshnet (including libp2p) into web assembly but there were many problems. The web assembly package was huge. Also, many of the network operations of libp2p are not allowed from web assembly. One of the main services of libp2p is to check for new connections (Bluetooth, wifi, etc.) and the manage those connections including direct TPC sockets. All of this is not allowed by web assembly inside the browser.

As you mention, another option is to run a weshnet node outside of the browser and use it from the browser with gRPC. You can't use a direct TCP socket (not allowed) but maybe gRPC has a WebSocket transport that is allowed from the browser.

Erudition commented 1 year ago

orbitdb in the browser currently works by using the browser-compatible transports. Weshnet should be able to use those in its libp2p configuration too, no? I'm fine with not having Bluetooth or other direct TCP transports, that's the current limitation of orbitdb anyway. I'm just looking for weshnet to have feature parity with orbitdb when used in the browser, even if that means just websockets/webrtc with relay servers.

Alternately, if the libp2p and ipfs of weshnet could be configurable, or we could use our own IPFS daemon instead of the one built into weshnet, this would all be possible again.

jefft0 commented 1 year ago

orbitdb in the browser uses the JavaScript version of orbitdb. Weshnet uses the Go version: https://github.com/berty/go-orbit-db That's why I mentioned the difficulty of using Go in the browser.

GitHub
GitHub - berty/go-orbit-db: Go version of P2P Database on IPFS
Go version of P2P Database on IPFS. Contribute to berty/go-orbit-db development by creating an account on GitHub.
Erudition commented 1 year ago

Yep, that's why I opened this issue. My thinking is, if weshnet is based on orbitdb, perhaps I can still use orbitdb directly in the browser to interact with the weshnet database for now?

jefft0 commented 1 year ago

Weshnet also has a lot of crypto and database functions that are all written in Go. Porting all of that to Javascript would be a major undertaking. For example, all of the packages in here: https://github.com/berty/weshnet/tree/main/pkg

GitHub
weshnet/pkg at main · berty/weshnet
Async Mesh Network Protocol for Extreme Communication -- Innovative, Resilient, and Decentralized - weshnet/pkg at main · berty/weshnet
Erudition commented 1 year ago

Okay, good to know - sounds like the answer is "no" for the foreseeable future, then.

Weshnet is only for native apps / apps with native access.

jefft0 commented 1 year ago

Yes, that's the case for now. Closing this issue.