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:
- Follow the installation instructions here
- Use the docker image:
docker run -it --network host -v "$(pwd)":"$(pwd)" -w "$(pwd)" dapphub/klab klab
Learning Klab
- Read the documentation on the spec format: https://github.com/dapphub/klab/blob/master/acts.md
- Look at the examples
- Look at the keybindings
- Work through the DevCon4 workshop: problems, solutions
Using this Repo
Preparation
- Add the project you wish to specify as a submodule in the
dapp
folder (git submodule add <REPO> dapp
) - Build the project (
(cd dapp && dapp build)
) - Open
config.json
and edit the implementations section to connect contract names in the spec with concrete bytecode implementations (*.sol.json
files).
Writing Specs
- Open
src/spec.act.md
and start writing your spec - Build the k expressions (
klab build
)
Verifying Code
- Run
klab prove <path_to_spec.k>
Exploring Proofs
- In one tab run
klab server
- In another run
klab run --spec <path_to_spec.k>