You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
@ameya-deshmukh thanks for offering! just checked in with @joemarshall who's down the rabbit hole already. we talked about an MVP version that he's getting started with. keep an eye out for updates or opportunities here.
@wolovim An initial PR that lets you build and run web3 on pyodide is here #3088
In the end I had to mock the aiohttp and websockets modules - the positives are that it gives you nice errors if you try and use async things - the negatives are that it is micropip / pyodide specific (but then pyodide is currently the only web python with decent package loading anyway). The alternative of separating out async would require quite a lot of code reorganisation in web3.py. Thoughts welcome on it. I guess I see it as being a stepping stone towards a time when pyodide supports aiohttp (client only) and websockets clients properly.
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:
The text was updated successfully, but these errors were encountered: