Open
Description
So, I did some work on running web3.py on webassembly / emscripten, so as to be able to run it in a web browser / jupyterlite notebook, without having to install any software on the user's machine.
This is potentially useful for teaching purposes, to be able to run demo code in the browser, but also worth doing, as webassembly is gaining quite a lot of traction in container / cloud platforms.
In terms of how this works, I see this work as being possible in multiple stages, each of which gains some functionality:
- Remove / make optional dependencies based on system.platform being wasm32-emscripten/ wasm32-wasi. Currently, aiohttp and websockets specifically don't work on webassembly. It is possible to run web3.py code by hacking in dummy modules for these two. This gets us the basic ability to run synchronous web3 calls, and to add emscripten to the project CI, so it keeps working.
- Add emscripten provider in web3.py for async_rpc, and websockets client connections. This would allow most functionality of web3.py, except for local ipc support. Currently aiohttp and websockets libraries don't have support for emscripten; it is possible that they won't, because there is some functionality of the libraries that will never work (server side anything), and even if a polyfill is made, some functionality may not behave exactly the same. I think it is probably worth having specific emscripten providers for this here instead..
- Potentially add support for ipc / geth on wasm32-wasi. This would be the final piece in the jigsaw in making all functionality work in webassembly container platforms, but to be honest I don't know if it is worth it - it will probably never work in browser / emscripten based webassembly.