-
Notifications
You must be signed in to change notification settings - Fork 968
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
Add full support for WebAssembly in both browser and Node.js environments #288
Conversation
The browser tests pass locally but I'm having some difficulty getting them to work in CI. There are a couple of issues:
Any ideas about how to address these? I'm not very familiar with TravisCI but it might just be a matter of configuring the tests to only run for certain versions of Go. It would be nice if the tests could run in CI to make sure that browser support doesn't break in the future. |
5ac28e2
to
3ff7350
Compare
I just pushed a few more commits which allow support for asynchronous BrowserFS backends (i.e. those that don't have support for functions with the For 0x Mesh we are now using BrowserFS backed by IndexedDB, which wasn't possible before. You can see this PR for more context. |
any update on this? go-ethereum fails to compile to wasm due the lack of support of wasm target by go-leveldb. |
@syndtr , any plans to merge this? Would be great to have Wasm support =) |
hello @albrow , I'm using your commit from 0xProject in the mean time by replacing in my go.mod, however I'm getting the following errors during build: Any ideas on what I'm missing or what could be happening? Thanks |
@simbadMarino I haven't worked with Go and WebAssembly in a few years. The |
Thanks for the quick reply! let me dig a bit into it :), will keep you posted EDIT: Most likely something in either of these commits broke something: |
I managed to fix it by using reflect to compare, if anyone is interested I created a fork which compiles wasm successfully on go v1.19.9: https://github.com/simbadMarino/goleveldb. Thanks! |
This PR expands on #277 (which supported Node.js only) and adds support for running
goleveldb
in the browser. This is accomplished by using BrowserFS and writingsyscall/js
bindings that mimic the functions and methods in the Go standard library. AFAIK there is no way for us to embed BrowserFS, so users will need to include and initialize it separately (typically inside of a script tag prior to loading the WebAssembly bytecode).This PR also includes a mechanism for running a small set of tests in a headless browser by simply running
go test
a the repository root. These tests require Node.js andnpm
.@syndtr if this is something you are interested in, we would love to get it merged upstream so that other people could make use of it. I imagine we will need to add some more documentation specifically around browser support. I also anticipate that you might want to tweak some things about the file structure, naming conventions, and how browser tests are run. Let me know if you have any questions or if there is anything I can do to help.