Skip to content
ipsilonPublic

About

Fast Ethereum Virtual Machine implementation

Topics

Resources

Stars

981 stars

Watchers

30 watching

Forks

Latest commit

 

History

3,211 Commits

Folders and files

Repository files navigation

evmone

ethereum badge readme style standard badge codecov badge codspeed badge circleci badge appveyor badge license badge

Fast Ethereum Virtual Machine implementation

evmone is a C++ implementation of the Ethereum Virtual Machine (EVM). Created by members of the Ipsilon (ex-Ewasm) team, the project aims for clean, standalone EVM implementation that can be imported as an execution module by Ethereum Client projects. The codebase of evmone is optimized to provide fast and efficient execution of EVM smart contracts.

Characteristic of evmone

  1. Exposes the EVMC API.
  2. Requires C++20 standard.
  3. The intx library is used to provide 256-bit integer precision.
  4. The ethash library is used to provide Keccak hash function implementation needed for the special KECCAK256 instruction.
  5. Contains two interpreters:
    • Baseline (default)
    • Advanced (select with the advanced option)

Baseline Interpreter

  1. Provides relatively straight-forward but efficient EVM implementation.
  2. Performs only minimalistic JUMPDEST analysis.

Advanced Interpreter

  1. The indirect call threading is the dispatch method used - a loaded EVM program is a table with pointers to functions implementing virtual instructions.
  2. The gas cost and stack requirements of block of instructions is precomputed and applied once per block during execution.
  3. Performs extensive and expensive bytecode analysis before execution.

Usage

As an EVMC module

evmone implements the EVMC API for Ethereum Virtual Machines. The evmone shared library can be loaded by an EVMC host application. Prebuilt libraries are available from Releases. evmone vendors EVMC (in evmc/); to be ABI compatible, the host application must use EVMC headers with the same ABI version (the vendored headers are in evmc/include).

Building from source

To build the evmone EVMC module (shared library), test, and benchmark:

  1. Fetch the source code:

    git clone --recursive https://github.com/ethereum/evmone
    cd evmone
    
  2. Configure the project build and dependencies:

    Linux / OSX
    cmake -S . -B build -DEVMONE_TESTING=ON
    
    Windows
    cmake -S . -B build -DEVMONE_TESTING=ON -G "Visual Studio 16 2019" -A x64
    
  3. Build:

    cmake --build build --parallel
    
  4. Run the unit tests or benchmarking tool:

    build/bin/evmone-unittests
    build/bin/evmone-bench test/evm-benchmarks/benchmarks
    

Precompiles

Ethereum Precompiled Contracts (precompiles for short) are implemented in two places: the core parts are in the evmone_precompiles library (lib/evmone_precompiles), and the dispatch is in the evmone state library (test/state), which is built with the evmone tools (EVMONE_TOOLS). Two CMake options switch a precompile to an external library instead:

  1. EVMONE_PRECOMPILES_LIBSECP256K1=ON uses libsecp256k1 for ecrecover. The built-in ecrecover has degraded performance, so this can be enabled to speed it up. The library is fetched and built with evmone.
  2. EVMONE_PRECOMPILES_GMP=ON uses GMP for expmod. This requires the GMP library (e.g. libgmp-dev) at build and execution time.

Docker

Note

This section is outdated: the Docker image is not updated regularly.

Docker images with evmone are available on Docker Hub: https://hub.docker.com/r/ethereum/evmone.

Having the evmone shared library inside a docker is not very useful on its own, but the image can be used as the base of another one or you can run benchmarks with it.

docker run --entrypoint evmone-bench ethereum/evmone /src/test/benchmarks

References

  1. Efficient gas calculation algorithm for EVM

Maintainer

Paweł Bylica @chfast

License

license badge

Licensed under the Apache License, Version 2.0.

About

Fast Ethereum Virtual Machine implementation

Topics

Resources

Stars

981 stars

Watchers

30 watching

Forks

Releases

Packages

Used by

Contributors

Languages