• Stars
    star
    180
  • Rank 213,027 (Top 5 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Hera: Ewasm virtual machine conforming to the EVMC API

Hera Status

Hera is an ewasm (revision 4) virtual machine implemented in C++ conforming to EVMC ABIv10.

It is designed to leverage various Wasm backends, both interpreters and AOT/JITs.

Client support

Hera has been tested with aleth and geth. It should however work with any client with compliant EVMC support.

Building Hera

First clone this repository and make sure the submodules are checked out:

$ git clone https://github.com/ewasm/hera
$ cd hera
$ git submodule update --init

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

Build options

  • -DHERA_DEBUGGING=ON will turn on debugging features and messages. This is off by default.
  • -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. aleth from aleth). This is the preferred way of compilation.

wabt support

Complete support.

wabt is built by default and needs no build options. It can be disabled with:

  • -DHERA_WABT=OFF

Binaryen support

Complete support.

Binaryen support needs to be enabled via the following build option and requested at runtime with engine=binaryen:

  • -DHERA_BINARYEN=ON will request the compilation of Binaryen support

WAVM support

Complete support.

WAVM support needs to be enabled via the following build option and requested at runtime with engine=wavm:

  • -DHERA_WAVM=ON will 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 the lib/cmake/llvm directory, such as /usr/local/Cellar/llvm/6.0.1/lib/cmake/llvm on Homebrew.

Runtime options

These are to be used via EVMC set_option:

  • engine=<engine> will select the underlying WebAssembly engine, where the only accepted values currently are binaryen, wabt, and wavm
  • metering=true will enable metering of bytecode at deployment using the Sentinel system contract (set to false by default)
  • benchmark=true will produce execution timings and output it to both standard error output and hera_benchmarks.log file.
  • evm1mode=<evm1mode> will select how EVM1 bytecode is handled
  • sys:<alias/address>=file.wasm will 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 that sys:sentinel=file.wasm and sys:evm2wasm=file.wasm are both valid. This option is intended for debugging purposes.

evm1mode

  • reject will reject any EVM1 bytecode with an error (the default setting)
  • fallback will allow EVM1 bytecode to be passed through to the client for execution
  • evm2wasm will enable transformation of bytecode using the EVM Transcompiler
  • runevm will transform EVM1 bytecode using runevm

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

Fuzzing

To enable fuzzing you need clang compiler and provide -DHERA_FUZZING=ON option to CMake. You should also enable both Binaryen and WABT engines. This will build additional executable hera-fuzzer. Check out its help and libFuzzer documentation.

test/fuzzing/hera-fuzzer -help=1

Author(s)

  • Alex Beregszaszi
  • Jake Lang

License

Apache 2.0

More Repositories

1

design

Ewasm Design Overview and Specification
1,015
star
2

evm2wasm

[ORPHANED] Transcompiles EVM code to eWASM
C++
107
star
3

ewasm-rust-api

Ewasm API for Rust
Rust
102
star
4

scout

Scout is a Ethereum 2.0 Phase 2 execution prototyping engine.
Rust
89
star
5

wasm-metering

[ORPHANED] Injects metering into webassembly binaries
JavaScript
68
star
6

testnet

Testnet planning & documentation
Dockerfile
64
star
7

ewasm-precompiles

Implementation of the Ethereum precompiled contracts in Rust.
Rust
45
star
8

wasm-json-toolkit

[ORPHANED] A small toolkit for converting wasm binaries into json and back.
JavaScript
32
star
9

ewasm-kernel

[ORPHANE] Javascript implementation of an eWASM VM
JavaScript
24
star
10

assemblyscript-ewasm-api

Ewasm API for AssemblyScript
TypeScript
21
star
11

biturbo

Eth1 EE using Turboproofs
TypeScript
20
star
12

rust-ewasm

[ORPHANE] Examples of compiling Rust code to ewasm contracts
WebAssembly
20
star
13

wast2wasm

[OBSOLETE] converts .wast files -> .wasm
JavaScript
20
star
14

benchmarking

Instructions for benchmarking Ewasm precompiles. (And results.)
Python
18
star
15

ewasm-studio

A lightweight development environment for eWASM
JavaScript
16
star
16

wrc20-examples

This repository contains examples of WRC20 tokens written in different languages.
12
star
17

sentinel-rs

Validator and metering injector for Ewasm
Rust
11
star
18

pm

Ewasm project management repository
11
star
19

ethereum-bls12.rs

Ethereum serialisation for BLS12-381 operations in Rust.
Rust
10
star
20

eth1x64

Description and examples for different variants under the Eth1x64 experiment.
8
star
21

scout.ts

TypeScript port of Scout
TypeScript
7
star
22

ethereum-bn128.rs

Ethereum's BN128 helpers for Rust.
Rust
7
star
23

scoutone

ScoutOne is a C++ library implementing the Eth 2 Phase 2 execution environment on top of wabt.
CMake
6
star
24

evm2wasm-frontend

[ORPHANE] an html front-end for evm2wasm
JavaScript
5
star
25

ewasm-cleanup

[OBSOLETE] Cleanup eWASM contracts to satisfy the specification
JavaScript
4
star
26

sentinel-governance

Governance prototype for the Sentinel contract
JavaScript
4
star
27

ewasm-explorer

[ORPHANE] Minimal account explorer for ewasm testnet.
JavaScript
2
star
28

hera.rs

Rust
2
star
29

ewasm-testgen

Random test case generator for Ewasm.
JavaScript
2
star
30

wasm-metering-old

[OBSOLETE] This is a prototype to inject metering into wasm code.
JavaScript
2
star
31

awesome-phase2

A curated list of awesome things related to Eth2 Phase2
2
star
32

ce-playground

This is a loose collection of Eth 2.0 Phase 2 Computational Environments (CE).
1
star
33

evm384_f6m_mul

Shell
1
star
34

docker

Docker sources useful for Ewasm
Dockerfile
1
star
35

ewasm-libc

1
star
36

ewasm-tests

[OBSOLETE] Tests.
1
star