Skip to content
K Semantics of the Ethereum Virtual Machine (EVM)
Makefile Shell Python Dockerfile CMake C
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmake Reduce build times by using cmake to build llvm backend (#484) Sep 16, 2019
deps Reduce build times by using cmake to build llvm backend (#484) Sep 16, 2019
media Trufflecon - Presentations and demo files added (#425) Aug 6, 2019
package Reduce build times by using cmake to build llvm backend (#484) Sep 16, 2019
tests add test files with multiple transactions (#493) Sep 18, 2019
.gitignore Update k submodule and remove references to rust (#474) Sep 5, 2019
.gitmodules Moves dependency submodules into `deps` directory, so that `.build` i… Jun 5, 2019
Dockerfile Update k submodule and remove references to rust (#474) Sep 5, 2019 Test release builds using Firefly (#407) Jul 30, 2019
Jenkinsfile LLVM backend is default (#483) Sep 12, 2019
LICENSE LICENSE: update copyright date Feb 22, 2019
Makefile Reduce build times by using cmake to build llvm backend (#484) Sep 16, 2019 Reduce build times by using cmake to build llvm backend (#484) Sep 16, 2019 Disassemble on the fly (#448) Sep 5, 2019 Implement #executeTx (#478) Sep 17, 2019 Disassemble on the fly (#448) Sep 5, 2019 Use Bytes type for concrete backends (#414) Jul 30, 2019 Fix master build and add regression testing (#440) Aug 15, 2019 Implement #executeTx (#478) Sep 17, 2019 Update Feb 27, 2018 make json parser work with default system python, both … Feb 9, 2018
kevm Reduce build times by using cmake to build llvm backend (#484) Sep 16, 2019 Configuration changes (#335) May 8, 2019 personal_importRawKey (#460) Aug 27, 2019 StatusCode for node (#399) Jul 17, 2019 Implement #executeTx (#478) Sep 17, 2019

KEVM: Semantics of EVM in K

In this repository we provide a model of the EVM in K.


These may be useful for learning KEVM and K (newest to oldest):

To get support for KEVM, please join our Riot Room.

Repository Structure

The following files constitute the KEVM semantics:

  • sets up some basic cryptographic primitives.
  • provides the (functional) data of EVM (256 bit words, wordstacks, etc...).
  • provides the status codes which are reported to an Ethereum client on execution exceptions.
  • is the main KEVM semantics, containing the configuration and transition rules of EVM.

These additional files extend the semantics to make the repository more useful:

  • is an execution harness for KEVM, providing a simple language for describing tests/programs.
  • defines high-level notations of eDSL, a domain-specific language for EVM specifications, for formal verification of EVM bytecode using K Reachability Logic Prover.
  • is the protobuf interface that an external Ethereum client can connect to for using KEVM as the execution engine.


K Backends

There are four backends of K available: LLVM (default) and OCaml for concrete execution and Java (default) and Haskell for symbolic execution. This repository generates the build-products for each backend in .build/defn/.

System Dependencies

The following are needed for building/running KEVM:

  • git
  • Pandoc >= 1.17 is used to generate the *.k files from the *.md files.
  • GNU Bison, Flex, and Autoconf.
  • GNU libmpfr and libtool.
  • Java 8 JDK (eg. OpenJDK)
  • Opam, important: Ubuntu users prior to 15.04 must build from source, as the Ubuntu install for 14.10 and prior is broken. opam repository also requires rsync.

On Ubuntu >= 18.04 (for example):

sudo apt install                                                       \
            autoconf bison clang++-8 clang-8 cmake curl flex gcc git   \
            libboost-test-dev libgmp-dev libjemalloc-dev libmpfr-dev   \
            libprocps-dev libprotobuf-dev libsecp256k1-dev libtool     \
            libyaml-dev libz3-dev lld-8 llvm-8 llvm-8-tools make maven \
            opam openjdk-11-jdk pandoc pkg-config protobuf-compiler    \
            z3 zlib1g-dev

On Ubuntu < 18.04, you'll need to skip libsecp256k1-dev and instead build it from source (via our Makefile):

make libsecp256k1

On ArchLinux:

sudo pacman -S                                              \
    base base-devel boost clang cmake crypto++ curl git gmp \
    jdk-openjdk jemalloc libsecp256k1 lld llvm maven mpfr   \
    opam python stack yaml-cpp z3 zlib

On OSX, using Homebrew, after installing the command line tools package:

brew tap caskroom/cask
brew cask install adoptopenjdk12
brew install automake libtool gmp mpfr pkg-config pandoc maven opam z3 libffi
make libsecp256k1

NOTE: a previous version of these instructions required the user to run brew link flex --force. After fetching this revision, you should first run brew unlink flex, as it is no longer necessary and will cause an error if you have the homebrew version of flex installed instead of the xcode command line tools version.

  • Haskell Stack. Note that the version of the stack tool provided by your package manager might not be recent enough. Please follow installation instructions from the Haskell Stack website linked above.

To upgrade stack (if needed):

stack upgrade
export PATH=$HOME/.local/bin:$PATH

Build K Dependency

Get the submodules:

git submodule update --init --recursive

And finally build the repository specific dependencies:

make RELEASE=1 deps

If you are a developer, you probably should omit RELEASE from the above commands unless you are testing performance, as the build is somewhat slower.

On Arch, instead do:

make LIBFF_CC=clang LIBFF_CXX=clang++ RELEASE=1 deps


Finally, you can install repository specific dependencies and build the semantics:

make build RELEASE=1

You can also build specific backends as so:

make build-haskell
make build-llvm RELEASE=1
make build-java

OPTIONAL: OCaml Backend

If you wish to build the OCaml backend, you will need to take some additional steps.

First, make sure you have our custom OCaml compiler installed (should only need to do this once):


Next you need to install the specific OCaml packages we requires:

make ocaml-deps

And next you can build the OCaml backend:

make build-ocaml


To install the kevm-vm binary for use in Firefly and other full-nodes, do:

make install RELEASE=1

You can set DESTDIR and INSTALL_PREFIX to change where the installation goes.

Example Usage

After building the definition, you can run the definition using ./kevm. Read the ./kevm script for examples of the actual invocations of krun that ./kevm makes.

Run the file tests/ethereum-tests/VMTests/vmArithmeticTest/add0.json:

./kevm run tests/ethereum-tests/VMTests/vmArithmeticTest/add0.json

To run proofs, you can similarly use ./kevm. For example, to prove one of the specifications:

./kevm prove tests/specs/ds-token-erc20/transfer-failure-1-a-spec.k -m VERIFICATION

Running Tests

The tests are run using the supplied Makefile. First, run make split-tests to generate some of the tests from the markdown files.

The following subsume all other tests:

  • make test: All of the quick tests.
  • make test-all: All of the quick and slow tests.

These are the individual test-suites (all of these can be suffixed with -all to also run slow tests):

When running tests with the Makefile, you can specify the TEST_CONCRETE_BACKEND (for concrete tests), or TEST_SYMBOLIC_BACKEND (for proofs).


This repository can build two pieces of documentation for you, the Jello Paper and the 2017 Devcon3 presentation.

System Dependencies

If you also want to build the Jello Paper, you'll additionally need:

sudo apt install python-pygments python-sphinx python-recommonmark
git clone ''
cd k-editor-support/pygments
easy_install --user .

For the 2017 Devcon3 presentation, you'll need pdflatex, commonly provided with texlive-full.

sudo apt install texlive-full


The Makefile supplies targets for building:

  • All media in this list: make media
  • Jello Paper documentation: make sphinx
  • 2017 Devcon3 presentation: make 2017-devcon3


For more information about The K Framework, refer to these sources:

You can’t perform that action at this time.