Skip to content

cyyber/zvmone

 
 

Repository files navigation

zvmone

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

Fast Zond Virtual Machine implementation

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

Characteristic of zvmone

  1. Exposes the ZVMC 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 ZVM implementation.
  2. Performs only minimalistic JUMPDEST analysis.

Advanced Interpreter

  1. The indirect call threading is the dispatch method used - a loaded ZVM 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 gzond plugin

zvmone implements the ZVMC API for Zond Virtual Machines. It can be used as a plugin replacing gzond's internal ZVM. But for that a modified version of gzond is needed. The Ewasm's fork of go-zond provides binary releases of gzond with ZVMC support.

Next, download zvmone from Releases.

Start the downloaded gzond with --vm.zvm option pointing to the zvmone shared library.

gzond --vm.zvm=./libzvmone.so

Building from source

To build the zvmone ZVMC module (shared library), test, and benchmark:

  1. Fetch the source code:

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

    Linux / OSX
    cmake -S . -B build -DZVMONE_TESTING=ON
    
    Windows
    cmake -S . -B build -DZVMONE_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/zvmone-unittests
    build/bin/zvmone-bench test/zvm-benchmarks/benchmarks
    

Tools

zvm-test

The zvm-test executes a collection of unit tests on any ZVMC-compatible Zond Virtual Machine implementation. The collection of tests comes from the zvmone project.

zvm-test ./zvmone.so

Docker

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

Having the zvmone 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 zvmone-bench ethereum/zvmone /src/test/benchmarks

References

  1. Efficient gas calculation algorithm for ZVM

Maintainer

Paweł Bylica @chfast

License

license badge

Licensed under the Apache License, Version 2.0.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 89.4%
  • CMake 9.1%
  • Python 0.9%
  • Makefile 0.3%
  • C 0.2%
  • Dockerfile 0.1%