Hera is an ewasm virtual machine implemented in C++ conforming to EVMC.
It can be used with aleth and perhaps in the future with other implementations through appropriate bindings.
Currently it uses Binaryen's interpreter for running WebAssembly bytecode and it should be improved to support wabt and wavm as backends.
-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.ethfrom [cpp-ethereum]).
Unfinished support, work in progress.
-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 value currently isbinaryenmetering=truewill enable metering of bytecode at deployment using the Sentinel system contract (set tofalseby default)evm2wasm=truewill enable metering of bytecode at deployment using the EVM Transcompiler (set tofalseby default)fallback=truewill allow EVM bytecode to be passed through to the client for execution (if set tofalse, the default, it will be rejected as invalid) (note: is ignored ifevm2wasmistrue)evm2wasm.js=truewill use aevm2wasm.jsas an external commandline tool instead of the system contractevm2wasm.js-trace=truewill turn on EVM tracing forevm2wasm.jsevm2wasm.cpp=truewill use aevm2wasmas a compiled-in dependency instead of the system contractevm2wasm.cpp-trace=truewill turn on EVM tracing forevm2wasm.cpp
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 transpiled code from evm2wasm. 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.
Although Hera enables the execution of ewasm bytecode, there are more elements to ewasm an Ethereum node must be aware of:
- backwards compatibility provisions
- injecting metering code to ewasm contracts
- transcompiling EVM1 contracts to ewasm if desired
All of the above must be implemented outside of Hera.
Alex Beregszaszi
Apache 2.0