-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[RFC] WASM #2191
[RFC] WASM #2191
Conversation
Supporting Wasm hasn't come up in any discussions thusfar, but why go-libp2p vs the Wasm support that rust-libp2p provides? |
Because I'm bad at rust (/ want to use it with the rest of my go code, like go-libipfs). |
The FX issue is fixed in master just unreleased: uber-go/fx@5e90c38 |
Celestia would support these efforts. We have a notion of Light Nodes that can access the chain state in trust minimized manner, and we want to experiment with running them in the browser over WebTransport/RTC. We don't have a rust implementation of the protocol and do not plan to have it soon, so Golang would be appreciated, even considering how inefficient it is. |
@Jorropo how much of go-libipfs compiles to wasm? What about kad and pubsub? I have some thoughts I've been drafting about a need to be able to compile protocols into a wasm module. Then have plumbing to allow every implementation to use the same wasm protocol module. I'll link them here when they're ready. As for this, it's definitely cool but I'm expecting not practical besides for demos. If you do get it to compile, my guess is that the bundled size will be pretty big (I hope I'm wrong!). So I don't expect core go-libp2p maintainers to spend effort maintaining this anytime soon. |
I would guess they work out of the box, given they don't call any io themselves. In general, anything compiles to wasm, the language is fully implemented, however the API you have access to are pretty limited.
You are probably right, however I don't think the bundle size maters much for let's say a browser application that implements a gateway, you download it once and then keep it cached. |
9e16381
to
94ef3b6
Compare
This was surpsingly easy there is a high chance I messed something up. This is a revert of 2d53c8f and then a bunch of fixes to bring it up to speed with the latest implementation. The fx change is related to this: uber-go/fx#1022
6fdaeba
to
accd448
Compare
Closing the PR as part of some spring cleaning. Still excited for this though :) |
I would like to run code in the browser however I hate JS and JS hates me.
It would be nice if
go-libp2p
would magically work in the browser (with gopherjs and orGOOS=js GOARCH=wasm
).IO would be provided in a degrated mode supporting websocket.
(https://pkg.go.dev/nhooyr.io/websocket#hdr-Wasm)We could also do webtransport and webrtc but we would need to write thesyscall/js
wrapping code ourselves which might be more or less complex.One potential issue which makes this less straight forward than it may seems, is that even if the big required elements like WS are reachable, the options that can be applied are way less diverse making some low level config impossible.
Current status of this PR:
It's probably worth removing it and relying exclusively on webtransport as long as https://developer.chrome.com/articles/websocketstream/ is not a thing. (we could also use a JS polyfill mapping websocket to the streaming API that webtransport is also using).
syscall/js
implementationWebRTCserverCertificateHashes
https://bugzilla.mozilla.org/show_bug.cgi?id=1806693