Git Product home page Git Product logo

evm-semantics's Introduction

KEVM: Semantics of EVM in K

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

Documentation/Support

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

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

Installing/Building

K Backends

There are four backends of K available, the OCAML and (experimental) LLVM backends for concrete execution, and the Java and (experimental) Haskell backends for symbolic reasoning and proofs. This repository generates the build-products for both non-experimental backends in .build/java/ and .build/ocaml/.

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 >= 15.04 (for example):

sudo apt-get install make git gcc maven openjdk-8-jdk bison flex opam pkg-config libmpfr-dev autoconf libtool pandoc zlib1g-dev z3 libz3-dev

On ArchLinux:

sudo pacman -S  base-devel rsync opam pandoc jre8-openjdk mpfr maven z3

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

brew tap caskroom/cask caskroom/version
brew cask install java8
brew install automake libtool gmp mpfr pkg-config pandoc maven opam z3

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.

Building

After installing the above dependencies, make sure the submodules are setup:

git submodule update --init --recursive

If you haven't already setup K's OCaml dependencies more recently than February 1, 2019, then you also need to setup the K OCaml dependencies:

./.build/k/k-distribution/src/main/scripts/bin/k-configure-opam-dev

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

make deps
make build

OPTIONAL: K LLVM/Haskell Backends

The K LLVM/Haskell backends, currently under development, require extra dependencies to work.

System Dependencies

  • 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

The LLVM backend has additional dependencies:

sudo apt-get install cmake clang-6.0 clang++-6.0 llvm-6.0 libboost-test-dev libgmp-dev libyaml-cpp-dev libjemalloc-dev curl

And you need to setup Rust:

curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
rustup toolchain install 1.28.0
rustup default 1.28.0

Building

After installing the above dependencies, the following command will build the extra backends into K:

  • make haskell-deps: additionally build the Haskell backend into K.
  • make llvm-deps: additionally build the LLVM backend into K.
  • make all-deps: additionally build both the Haskell and LLVM backends into K.

Following this dependency setup, you can also now kompile the LLVM and Haskell backends:

make build-haskell
make build-llvm

This Repository

The following files constitute the KEVM semantics:

  • krypto.md sets up some basic cryptographic primitives.
  • data.md provides the (functional) data of EVM (256 bit words, wordstacks, etc...).
  • evm.md 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:

  • driver.md is an execution harness for KEVM, providing a simple language for describing tests/programs.
  • analysis.md contains any automated analysis tools we develop.
  • edsl.md defines high-level notations of eDSL, a domain-specific language for EVM specifications, for formal verification of EVM bytecode using K Reachability Logic Prover.

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

Run the same file as a test:

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

To run proofs, you can similarly use ./kevm. For example, to prove the specification tests/proofs/specs/vyper-erc20/totalSupply-spec.k:

./kevm prove tests/proofs/specs/vyper-erc20/totalSupply-spec.k

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

Media

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-get install python-pygments python-sphinx python-recommonmark
git clone 'https://github.com/kframework/k-editor-support'
cd k-editor-support/pygments
easy_install --user .

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

sudo apt-get install texlive-full

Building

The Makefile supplies targets for building:

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

Resources

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

evm-semantics's People

Contributors

15joeybloom avatar andreistefanescu avatar asymmetric avatar brrmorre avatar daejunpark avatar denis-bogdanas avatar dwightguth avatar ehildenb avatar eviefp avatar fulldecent avatar grosu avatar livnev avatar mhhf avatar mrchico avatar msaxena2 avatar nishantjr avatar pdaian avatar pirapira avatar shogochiai avatar tomtomjhj avatar traiansf avatar yzhang90 avatar zhuxiaoran07 avatar zzma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.