Skip to content

Commit de97bf1

Browse files
anvacarurv-auditorpalinatolmach
authored
Update VERIFICATION.md (#2337)
* VERIFICATION.md: update docs * VERIFICATION.md: add legacy debugger mention * Set Version: 1.0.486 * Apply suggestions from code review Co-authored-by: Palina Tolmach <[email protected]> --------- Co-authored-by: devops <[email protected]> Co-authored-by: Palina Tolmach <[email protected]>
1 parent 956658a commit de97bf1

File tree

4 files changed

+23
-64
lines changed

4 files changed

+23
-64
lines changed

VERIFICATION.md

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
Verification Instructions for KEVM
22
==================================
33

4+
If you're trying to analyze Solidity smart contracts with symbolic execution, check out our guide for Kontrol at [docs.runtimeverification.com/kontrol].
5+
46
We assume that KEVM is installed, and the [K tutorial] has been completed.
57
This document provides instructions for kompiling and running claims using KEVM.
68

79
In `tests/specs/examples`, you can find a few examples to get you started on proving with kevm.
810

9-
Example 1: Sum to N
10-
-------------------
11+
Example: Sum to N
12+
-----------------
1113

1214
Have a look at the [sum-to-n-spec.k] file.
1315
It has two modules:
@@ -18,95 +20,52 @@ It has two modules:
1820
The first step is kompiling the `.k` file with the below command.
1921

2022
```sh
21-
kevm kompile-spec sum-to-n-spec.k --target haskell --syntax-module VERIFICATION --main-module VERIFICATION --definition sum-to-n-spec/haskell
23+
kevm kompile-spec sum-to-n-spec.k --target haskell --syntax-module VERIFICATION --main-module VERIFICATION --output-definition sum-to-n-spec/haskell
2224
```
2325

2426
In this example, the arguments used are:
2527

2628
- `--target haskell`: specify which symbolic backend to use for reasoning.
2729
- `--syntax-module VERIFICATION`: explicitly state the syntax module.
2830
- `--main-module VERIFICATION`: explicitly state the main module.
29-
- `--definition sum-to-n-spec/haskell`: the path where the kompiled definition is stored.
31+
- `--output-definition sum-to-n-spec/haskell`: the path where the kompiled definition is stored.
3032

3133
Next, run the prover with:
3234

3335
```sh
34-
kevm prove sum-to-n-spec.k --definition sum-to-n-spec/haskell
36+
kevm prove-legacy sum-to-n-spec.k --definition sum-to-n-spec/haskell
3537
```
3638

3739
The expected output is `#Top` which represents that all the claims have been proven.
3840

39-
Example 2: Faulty ERC20
40-
-----------------------
41-
42-
This example will describe the process of running claims for an ERC20 contract.
43-
Have a look at [erc20-spec.md].
44-
It contains claims for a few basic ERC20 properties and the helper modules required to run the proofs.
45-
The ERC20 Solidity contract that is tested is [ERC20.sol].
46-
47-
In this example, we rely on a helper module, `ERC20-VERIFICATION`, which must be generated from the [ERC20.sol] Solidity contract.
48-
The module is generated using the following `solc-to-k` command.
49-
50-
```sh
51-
kevm solc-to-k ERC20.sol ERC20 --main-module ERC20-VERIFICATION > erc20-bin-runtime.k
52-
```
53-
54-
- `solc-to-k` will parse a Solidity contract and generate a helper K module.
55-
- `--main-module` is used to set the name of the module.
41+
Debugging a proof
42+
-----------------
5643

57-
The generated `erc20-bin-runtime.k` file contains K rules and productions for the contract’s bytecode, storage indexes for the state variables, and function selectors, among others.
58-
These rules are then used in the claims. As an example, the `#binRuntime(ERC20)` production, which is found in the `<program>` cell, will rewrite to `#parseByteStack (contractBytecode)`, parsing the hexadecimal string into a `ByteStack`.
44+
For `kevm prove-legacy`, you can use the `--debugger` flag to debug a proof. With it, you can use `step`/`stepf` to navigate through the rewrite steps and `konfig` to display the K configuration. You can see all the available commands using `help`.
5945

60-
Following this, we can compile the Markdown file with:
61-
62-
```sh
63-
kevm kompile-spec erc20-spec.md --syntax-module VERIFICATION --main-module VERIFICATION --definition erc20-spec/haskell
64-
```
65-
66-
Next, run the prover with:
67-
68-
```sh
69-
kevm prove erc20-spec.md --definition erc20-spec/haskell --claim ERC20-SPEC.decimals
70-
```
71-
72-
Here, `--claim` tells the prover to run only the `decimals` spec from the `ERC20-SPEC` module.
73-
74-
More to know
75-
------------
76-
77-
To prove one of the specifications:
78-
79-
```sh
80-
kevm prove tests/specs/erc20/ds/transfer-failure-1-a-spec.k --definition tests/specs/erc20/verification/haskell
81-
```
82-
83-
You can also debug proofs interactively:
84-
85-
```sh
86-
kevm prove tests/specs/erc20/ds/transfer-failure-1-a-spec.k --definition tests/specs/erc20/verification/haskell --debugger
87-
```
88-
89-
In addition to this, you can use `kevm show-kcfg ...` or `kevm view-kcfg ...` to get a visualization.
46+
For `kevm prove`, you can use `kevm show-kcfg ...` or `kevm view-kcfg ...` to get a visualization.
47+
***Note:*** this is not compatible with `kevm prove-legacy`.
9048

9149
`kevm view-kcfg [spec_file] [--save-directory save_directory] [--claim claim_label] ...` command takes the same basic arguments as `kevm prove ...` does, including:
92-
- `spec_file` is the file to look in for specifications. This file is read like with `kevm prove —pyk …`; the `KProve.get_claims` invokes the frontend.
93-
- `--save_directory` must be passed as where the KCFGs have been saved (by a previous call to `kevm prove --save-directory save_directory ...`
94-
- `--claim claim_label` option is added, but unlike the `kevm prove ...`, you can only repeat it once. This option lets you select an individual claim out of the `spec_file`; if not supplied, it’s assumed that only one spec is present.
50+
- `spec_file` is the file to look in for specifications. This is the same file that is used for `kevm prove `.
51+
- `--save-directory` must be passed as where the KCFGs have been saved (by a previous call to `kevm prove --save-directory save_directory ...`)
52+
- `--claim claim_label` lets you select an individual claim out of the `spec_file`. If the flag is ommited, it’s assumed that only one claim is present. If the flag is ommited and more than one claim is present in the `spec_file` then an error will be raised.
9553
- `--spec-module spec_module` is also an inherited option.
9654

9755
The interactive KCFG (`view-kcfg`) puts your terminal in *application mode*. To select text in this mode, hold the modifier key provided by your terminal emulator (typically SHIFT or OPTION) while clicking and dragging. Refer to the [Textualize documentation](https://github.com/Textualize/textual/blob/main/FAQ.md#how-can-i-select-and-copy-text-in-a-textual-app) for more information.
9856

57+
`kevm show-kcfg [spec_file] [--save-directory save_directory] [--claim claim_label] ...` command is pretty similar, but prints out the K Control Flow Graph to `stdout` instead.
58+
9959
A running example:
10060

10161
```sh
10262
mkdir kcfgs
103-
kevm kompile-spec tests/specs/benchmarks/verification.k --definition tests/specs/benchmarks/verification/haskell --main-module VERIFICATION --syntax-module VERIFICATION
63+
kevm kompile-spec tests/specs/benchmarks/verification.k --output-definition tests/specs/benchmarks/verification/haskell --main-module VERIFICATION --syntax-module VERIFICATION
10464
kevm prove tests/specs/benchmarks/address00-spec.k --definition tests/specs/benchmarks/verification/haskell --verbose --save-directory kcfgs
105-
kevm view-kcfg --verbose kcfgs tests/specs/benchmarks/address00-spec.k --definition tests/specs/benchmarks/verification/haskell
65+
kevm view-kcfg tests/specs/benchmarks/address00-spec.k --save-directory kcfgs --definition tests/specs/benchmarks/verification/haskell
10666
```
10767

10868
[sum-to-n-spec.k]: <./tests/specs/examples/sum-to-n-spec.k>
109-
[erc20-spec.md]: <./tests/specs/examples/erc20-spec.md>
110-
[ERC20.sol]: <./tests/specs/examples/ERC20.sol>
11169
[K tutorial]: <https://github.com/runtimeverification/k/tree/master/k-distribution/k-tutorial>
11270
[more about it here]: <https://github.com/runtimeverification/k/tree/master/k-distribution/k-tutorial/1_basic/20_backends#k-backends>
71+
[docs.runtimeverification.com/kontrol]: <https://docs.runtimeverification.com/kontrol/>

kevm-pyk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "kevm-pyk"
7-
version = "1.0.485"
7+
version = "1.0.486"
88
description = ""
99
authors = [
1010
"Runtime Verification, Inc. <[email protected]>",

kevm-pyk/src/kevm_pyk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
from typing import Final
77

88

9-
VERSION: Final = '1.0.485'
9+
VERSION: Final = '1.0.486'

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.485
1+
1.0.486

0 commit comments

Comments
 (0)