d-xo / klab-learn-spec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Klab Starter Pack

This is a template repo and small tutorial for those interested in getting started specifying smart contracts with klab.

klab is a smart contract specification language and proof explorer. A Klab spec can be thought of as an extremely thorough test suite that can be run against any evm bytecode.

Using klab we can show:

  • The spec covers every possible execution (is exhaustive)
  • All specified behaviours hold for every possible execution

Running Klab

Either:

  1. Follow the installation instructions here
  2. Use the docker image: docker run -it --network host -v "$(pwd)":"$(pwd)" -w "$(pwd)" dapphub/klab klab

Learning Klab

  1. Read the documentation on the spec format: https://github.com/dapphub/klab/blob/master/acts.md
  2. Look at the examples
  3. Look at the keybindings
  4. Work through the DevCon4 workshop: problems, solutions

Using this Repo

Preparation

  1. Add the project you wish to specify as a submodule in the dapp folder (git submodule add <REPO> dapp)
  2. Build the project ((cd dapp && dapp build))
  3. Open config.json and edit the implementations section to connect contract names in the spec with concrete bytecode implementations (*.sol.json files).

Writing Specs

  1. Open src/spec.act.md and start writing your spec
  2. Build the k expressions (klab build)

Verifying Code

  1. Run klab prove <path_to_spec.k>

Exploring Proofs

  1. In one tab run klab server
  2. In another run klab run --spec <path_to_spec.k>

About

License:GNU Affero General Public License v3.0


Languages

Language:GCC Machine Description 100.0%