• Stars
    star
    236
  • Rank 170,480 (Top 4 %)
  • Language Isabelle
  • License
    Other
  • Created about 8 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

A Lem formalization of EVM and some Isabelle/HOL proofs

Formalization of Ethereum Virtual Machine in Lem

Build Status CircleCI

This repository contains

  • an EVM implementation in Lem lem/evm.lem
  • a Keccak-256 implementation in Lem lem/keccak.lem
  • a form of functional correctness defined in Lem lem/evmNonExec.lem
  • a relational semantics that captures the environment's nondeterministic behavior RelationalSem.thy
  • some example verified contracts in example
  • a parser that parses hex code and emits an Isabelle/HOL expression representing the program parser/hexparser.rb

When you see \<Rightarrow> in the source, try using the Isabelle2017 interface. There you see ⇒ instead.

Lem?

Lem is a language that can be translated into Coq, Isabelle/HOL, HOL4, OCaml, HTML and LaTeX.

Prerequisites

  • Isabelle2017
  • lem
  • OCaml 4.02.3
  • opam 1.2.2
  • Some opam packages: use opam install ocamlfind batteries yojson bignum easy-format bisect_ppx ocamlbuild sha secp256k1
  • ECC-OCaml from mrsmkl
  • secp256k1
    • On Ubuntu Artful, apt install secp256k1-0 secp256k1-dev is enough
    • On older versions of Ubuntu, installation from the current master branch is necessary
    • configure option --enable-module-recovery is needed

How to read the proofs

First translate the Lem definitions into Isabelle/HOL:

$ make lem-thy

Then, use Isabelle2017 to open ./examples/AlwaysFail.thy. The prerequisite Isabelle/HOL files are automatically opened.

How to run VM tests and state tests

Make sure the tests submodule is cloned

$ git submodule init tests
$ git submodule update tests

Extract the OCaml definitions

$ make lem-ocaml

And move to tester directory.

$ cd tester

One way is to run the VM Test.

$ sh compile.sh
$ ./runVmTest.native

(When ./runVmTest.native takes an argument, it executes only the test cases whose names contain the argument as a substring.)

Another way is to run the VM Test and measure the coverage.

$ sh measure_coverage.sh

Moreover, it's possible to run Blockchain Tests.

$ ./runBlockchainTest.native

Makefile goals

  • make doc produces output/document.pdf as well as lem/*.pdf.
  • make lem-thy compiles the Lem sources into Isabelle/HOL
  • make lem-hol compiles the Lem sources into HOL4
  • make lem-coq; cd lem; make compiles the Lem sources into Coq (and then compiles the Coq sources)
  • make lem-pdf compiles some of the Lem sources into PDF through LaTeX
  • make all-isabelle checks all Isabelle/HOL sources (but not the ones compiled from Lem)
  • make does everything above
  • script/gen_coq.sh generates a distribution useful for Coq users

Links

More Repositories

1

awesome-ethereum-virtual-machine

Ethereum Virtual Machine Awesome List
839
star
2

bamboo

Bamboo see https://github.com/cornellblockchain/bamboo
OCaml
324
star
3

ethereum-formal-verification-overview

The start page about my efforts around smart contract verification
298
star
4

coq2rust

Coq to Rust program extraction. The whole tree is on the original Coq code base.
OCaml
214
star
5

evmverif

An EVM code verification framework in Coq
Coq
44
star
6

dry-analyzer

Dr. Y's Ethereum Contract Analyzer
Coq
42
star
7

vmtrace_visualizer

A program that annotates a vm trace with dataflow information
Ruby
35
star
8

ethereum-word-list

Words are Hard: Defining Common Terms in the Ethereum / Crypto Space
22
star
9

gohantabeyo

Gohantabeyo is a web site where people can make a wish whom they want to eat out with. If the other makes a similar wish, their wishes are told to both.
Ruby
15
star
10

cbc_casper

Isabelle formalization of binary consensus
Isabelle
8
star
11

record

6
star
12

neta

neta notes
HTML
5
star
13

rlp-ocaml

RLP serialization for OCaml
OCaml
4
star
14

practice

JavaScript
3
star
15

kissdb-rust

kissdb ported to rust
Rust
3
star
16

sql2lisp

Verilog
3
star
17

verbose-code-reading

Verboselly Logged Code Reading
2
star
18

token_why3

A Why3 modelling of a token contract
Coq
2
star
19

surreal

surreal numbers in Coq
Verilog
2
star
20

proofmarket

2
star
21

kietter

kietter
Ruby
2
star
22

js-graph-it-with-containers

a fork of http://js-graph-it.sourceforge.net/
JavaScript
2
star
23

ethereum-formal-list

A list of formal method applications on smart contracts
1
star
24

undecidable

undecidability club's web page
1
star
25

async_lazy_rpc

Haskell
1
star
26

taocp_in_coq

taocp_in_coq
1
star
27

htodo

a todo manager
Haskell
1
star
28

CLTT

Verilog
1
star
29

lifepicker

A randomized activity picker for your 5 minites
Python
1
star
30

waitfree

A combinator library for asynchronous waitfree computation among forkIO threads.
Haskell
1
star
31

haskell-twitter

1
star
32

thesis

1
star
33

game

combinatorial game
Verilog
1
star
34

ConcurrentSet

Haskell
1
star
35

pirapira.github.io

HTML
1
star
36

salary-nego

Salary negotiation app on the Nexus zkVM
Rust
1
star