Hera is an ewasm (revision 4) virtual machine implemented in C++ conforming to EVMC ABIv5.
It is design to leverage various Wasm backends, both interpreters and AOT/JITs.
Hera has been tested with aleth. It should however work with any client with compliant EVMC support.
First clone this repository and make sure the submodules are checked out:
$ git clone https://github.com/ewasm/hera
$ cd hera
$ git submodule update --initThe preferred way is building Hera as a shared library:
$ mkdir build
$ cd build
$ cmake -DBUILD_SHARED_LIBS=ON ..
$ cmake --build .In this case the built library will be placed at build/src/libhera/libhera.so on Linux or build/src/libhera/libhera.dylib on MacOS.
Please also check the build options listed in the following section.
-DHERA_DEBUGGING=ONwill turn on debugging features and messages-DBUILD_SHARED_LIBS=ONis a standard CMake option to build libraries as shared. This will build Hera shared library that can be then dynamically loaded by EVMC compatible Clients (e.g.alethfrom aleth). This is the preferred way of compilation.
Complete support.
Binaryen is always built and needs no build options.
Limited support, work in progress.
wabt support needs to be enabled via the following build option and requested at runtime with engine=wabt:
-DHERA_WABT=ONwill request the compilation of wabt support
Limited support, work in progress.
WAVM support needs to be enabled via the following build option and requested at runtime with engine=wavm:
-DHERA_WAVM=ONwill request the compilation of WAVM support-DLLVM_DIR=...one will need to specify the path to LLVM's CMake file. In most installations this has to be within thelib/cmake/llvmdirectory, such as/usr/local/Cellar/llvm/6.0.1/lib/cmake/llvmon Homebrew.
These are to be used via EVMC set_option:
engine=<engine>will select the underlying WebAssembly engine, where the only accepted values currently arebinaryen,wabt, and 'wavm'metering=truewill enable metering of bytecode at deployment using the Sentinel system contract (set tofalseby default)evm1mode=<evm1mode>will select how EVM1 bytecode is handledsys:<alias/address>=file.wasmwill override the code executing at the specified address with code loaded from a filepath at runtime. This option supports aliases for system contracts as well, such thatsys:sentinel=file.wasmandsys:evm2wasm=file.wasmare both valid. This option is intended for debugging purposes.
rejectwill reject any EVM1 bytecode with an error (the default setting)fallbackwill allow EVM1 bytecode to be passed through to the client for executionevm2wasmwill enable transformation of bytecode using the EVM Transcompilerevm2wasm.jswill use aevm2wasm.jsas an external commandline tool instead of the system contractevm2wasm.js-tracewill useevm2wasm.jswith tracing option turned onevm2wasm.cppwill use aevm2wasmas a compiled-in dependency instead of the system contractevm2wasm.cpp-tracewill turn useevm2wasmwith tracing option turned on
Hera implements two interfaces: EEI and a debugging module.
debug::print32(value: i32)- print valuedebug::print64(value: i64)- print valuedebug::printMem(offset: i32, len: i32)- print memory segment as printable charactersdebug::printMemHex(offset: i32, len: i32)- print memory segment as hexdebug::printStorage(pathOffset: i32)- print storage value as printable charactersdebug::printStorageHex(pathOffset: i32)- print storage value as hex
These are only enabled if Hera is compiled with debugging on.
debug::evmTrace(pc: i32, opcode: i32, cost: i32, sp: i32)
This is useful to trace the translated code by EVM Transcompiler. This is only enabled if Hera is compiled with debugging on.
Note: it is valid to invoke evmTrace with a negative value for sp. In this case, no stack values will be printed.
Alex Beregszaszi, Jake Lang
Apache 2.0