PyOffcahin is a Truebit custom WASM interpreter/tool. It has been written to be fairly modular and flexible(at the cost of being slower but speed is not a concern) so it can be used as a wasm python library as well.
Right now PyOffchain can:
run very simple wasm files.
pretty dump info on the wasm file.
In the future:
have a linker.
have an assembler and a disassembler.
To clone the repo you should:
git clone https://github.com/ronin010011/tb-wasm-machine-poc
The submodule is the WASM testsuite. If you are not planning on developing python-offchain you can leave this be otherwise run:
git submodule init
git submodule update
To get the wasm objects for the testsuite, run the script names testsuiteobjectify.sh
and pass it the name of the assembler you're using:
For wabt:
./testsuiteobjectify.sh wast2wasm
For binaryen:
./testsuiteobjectify.sh wasm-as
There are a total of four options that give you pretty dumps of a wasm file:
--sectiondump
: dumps the hex of a section given by its name.--hexdump
: dumps the whole wasm file in hex format. Expects an integer for the number of bytes to show in each line.--dbgsection
: dumps a section given by name in a human friendly format.--dbg
: dumps the whole wasm file in a human friendly format.--memdump
: dumps the linear memory starting from offset zero til the given address.--idxspc
: dumps the index space a human friendly format.
If this is the first time you are hearing about stack machines, you can check out a very simple stack machine interpreter.
It is a very simple stack machine. You have been warned.