Hera: ewasm virtual machine conforming to the EVMC API (Evacuated from NSA/Microsoft Github)

Alex Beregszaszi d3a747abc8 Merge pull request #247 from ewasm/uint128 6 years ago
cmake 604985bbbf CMake: Fix missing include 6 years ago
evm2wasm @ 96516ce391 64f1c5811c Add evm2wasm submodule 6 years ago
evmc @ c633aa4c28 26102afdbb Upgrade EVMC 6 years ago
scripts 82572c86e3 Test evm2wasm in CircleCI (and add test script) 6 years ago
src 39135a84eb Use int128 compiler extension for ensureSenderBalance 6 years ago
.gitignore 9878f6a768 Add CMake and build Binaryen as ExternalProject 6 years ago
.gitmodules d0b8421029 Support invoking the C++ evm2wasm directly 6 years ago
CMakeLists.txt 28b3256e1d Add -Werror to CFLAGS 6 years ago
LICENSE bdbd0cc3e9 Initial import 8 years ago
README.md fd89562c7d Merge pull request #233 from ewasm/evm2wasm-api 6 years ago
circle.yml 82572c86e3 Test evm2wasm in CircleCI (and add test script) 6 years ago

README.md

Hera Status

Hera is an ewasm virtual machine implemented in C++ conforming to EVMC.

It can be used with cpp-ethereum 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.

Build options

  • -DHERA_DEBUGGING=ON will turn on debugging features and messages
  • -DBUILD_SHARED_LIBS=ON is 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. eth from cpp-ethereum).

Runtime options

These are to be used via EVM-C set_option:

  • metering=true will enable metering of bytecode at deployment using the Sentinel system contract (set to false by default)
  • evm2wasm=true will enable metering of bytecode at deployment using the EVM Transcompiler (set to false by default)
  • fallback=true will allow EVM bytecode to be passed through to the client for execution (if set to false, the default, it will be rejected as invalid) (note: is ignored if evm2wasm is true)
  • evm2wasm.js=true will use a evm2wasm.js as an external commandline tool instead of the system contract
  • evm2wasm.js-trace=true will turn on EVM tracing for evm2wasm.js
  • evm2wasm.cpp=true will use a evm2wasm as a compiled-in dependency instead of the system contract
  • evm2wasm.cpp-trace=true will turn on EVM tracing for evm2wasm.cpp

Interfaces

Hera implements two interfaces: EEI and a debugging module.

Debugging module

  • debug::print32(value: i32) - print value
  • debug::print64(value: i64) - print value
  • debug::printMem(offset: i32, len: i32) - print memory segment as printable characters
  • debug::printMemHex(offset: i32, len: i32) - print memory segment as hex
  • debug::printStorage(pathOffset: i32) - print storage value as printable characters
  • debug::printStorageHex(pathOffset: i32) - print storage value as hex

These are only enabled if Hera is compiled with debugging on.

EVM Tracing

  • 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.

Caveats

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.

Author(s)

Alex Beregszaszi

License

MIT