Skip to content

Commit

Permalink
Pull in changes to KEVM since project creation (#43)
Browse files Browse the repository at this point in the history
* src/{kontrol,tests}: import changes in KEVM since last import

* Set Version: 0.1.4

* src/tests/integratiion/test_foundry_prove: bring back upped recursion limit

* src/tests/unit/test_solc_to_k: add unit test harness

* .github/test-pr: disable failing if any in matrix fails

* .github/test-pr: build haskell backend too

* Set Version: 0.1.5

* kontrol/cli: update to latest KEVM foundry_test_args

* Set Version: 0.1.7

---------

Co-authored-by: devops <[email protected]>
  • Loading branch information
ehildenb and devops authored Sep 26, 2023
1 parent a012b23 commit 9d6dbd3
Show file tree
Hide file tree
Showing 13 changed files with 1,424 additions and 212 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
name: 'Profiling'
runs-on: [self-hosted, linux, normal]
strategy:
fail-fast: false
matrix:
backend: ['legacy', 'booster']
timeout-minutes: 30
Expand Down Expand Up @@ -94,6 +95,7 @@ jobs:
name: 'Integration Tests'
runs-on: [self-hosted, linux, normal]
strategy:
fail-fast: false
matrix:
backend: ['legacy', 'booster']
timeout-minutes: 240
Expand All @@ -109,7 +111,7 @@ jobs:
- name: 'Build KEVM'
run: |
docker exec -u github-user kontrol-ci-integration-${GITHUB_SHA} /bin/bash -c 'poetry install'
docker exec -u github-user kontrol-ci-integration-${GITHUB_SHA} /bin/bash -c 'CXX=clang++-14 poetry run kevm-dist --verbose build -j`nproc` plugin foundry'
docker exec -u github-user kontrol-ci-integration-${GITHUB_SHA} /bin/bash -c 'CXX=clang++-14 poetry run kevm-dist --verbose build -j`nproc` plugin haskell foundry'
- name: 'Run integration tests'
run: |
TEST_ARGS=
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.6
0.1.7
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kontrol"
version = "0.1.6"
version = "0.1.7"
description = "Foundry integration for KEVM"
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
57 changes: 26 additions & 31 deletions src/kontrol/__main__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from __future__ import annotations

import argparse
import json
import logging
import re
import sys
from argparse import ArgumentParser
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -145,7 +143,7 @@ def exec_prove(
max_depth: int = 1000,
max_iterations: int | None = None,
reinit: bool = False,
tests: Iterable[tuple[str, str | None]] = (),
tests: Iterable[tuple[str, int | None]] = (),
exclude_tests: Iterable[str] = (),
workers: int = 1,
simplify_init: bool = True,
Expand Down Expand Up @@ -218,7 +216,7 @@ def exec_prove(
def exec_show(
foundry_root: Path,
test: str,
id: str | None,
version: int | None,
nodes: Iterable[NodeIdLike] = (),
node_deltas: Iterable[tuple[NodeIdLike, NodeIdLike]] = (),
to_module: bool = False,
Expand All @@ -234,7 +232,7 @@ def exec_show(
output = foundry_show(
foundry_root=foundry_root,
test=test,
id=id,
version=version,
nodes=nodes,
node_deltas=node_deltas,
to_module=to_module,
Expand All @@ -249,18 +247,18 @@ def exec_show(
print(output)


def exec_to_dot(foundry_root: Path, test: str, id: str | None, **kwargs: Any) -> None:
foundry_to_dot(foundry_root=foundry_root, test=test, id=id)
def exec_to_dot(foundry_root: Path, test: str, version: int | None, **kwargs: Any) -> None:
foundry_to_dot(foundry_root=foundry_root, test=test, version=version)


def exec_list(foundry_root: Path, **kwargs: Any) -> None:
stats = foundry_list(foundry_root=foundry_root)
print('\n'.join(stats))


def exec_view_kcfg(foundry_root: Path, test: str, id: str | None, **kwargs: Any) -> None:
def exec_view_kcfg(foundry_root: Path, test: str, version: int | None, **kwargs: Any) -> None:
foundry = Foundry(foundry_root)
test_id = foundry.get_test_id(test, id)
test_id = foundry.get_test_id(test, version)
contract_name, _ = test_id.split('.')
proof = foundry.get_apr_proof(test_id)

Expand All @@ -275,14 +273,14 @@ def _custom_view(elem: KCFGElem) -> Iterable[str]:
viewer.run()


def exec_remove_node(foundry_root: Path, test: str, node: NodeIdLike, id: str | None, **kwargs: Any) -> None:
foundry_remove_node(foundry_root=foundry_root, test=test, id=id, node=node)
def exec_remove_node(foundry_root: Path, test: str, node: NodeIdLike, version: int | None, **kwargs: Any) -> None:
foundry_remove_node(foundry_root=foundry_root, test=test, version=version, node=node)


def exec_simplify_node(
foundry_root: Path,
test: str,
id: str | None,
version: int | None,
node: NodeIdLike,
replace: bool = False,
minimize: bool = True,
Expand All @@ -301,7 +299,7 @@ def exec_simplify_node(
pretty_term = foundry_simplify_node(
foundry_root=foundry_root,
test=test,
id=id,
version=version,
node=node,
replace=replace,
minimize=minimize,
Expand All @@ -317,7 +315,7 @@ def exec_simplify_node(
def exec_step_node(
foundry_root: Path,
test: str,
id: str | None,
version: int | None,
node: NodeIdLike,
repeat: int = 1,
depth: int = 1,
Expand All @@ -335,7 +333,7 @@ def exec_step_node(
foundry_step_node(
foundry_root=foundry_root,
test=test,
id=id,
version=version,
node=node,
repeat=repeat,
depth=depth,
Expand All @@ -349,17 +347,17 @@ def exec_step_node(
def exec_merge_nodes(
foundry_root: Path,
test: str,
id: str | None,
version: int | None,
nodes: Iterable[NodeIdLike],
**kwargs: Any,
) -> None:
foundry_merge_nodes(foundry_root=foundry_root, node_ids=nodes, test=test, id=id)
foundry_merge_nodes(foundry_root=foundry_root, node_ids=nodes, test=test, version=version)


def exec_section_edge(
foundry_root: Path,
test: str,
id: str | None,
version: int | None,
edge: tuple[str, str],
sections: int = 2,
replace: bool = False,
Expand All @@ -377,7 +375,7 @@ def exec_section_edge(
foundry_section_edge(
foundry_root=foundry_root,
test=test,
id=id,
version=version,
edge=edge,
sections=sections,
replace=replace,
Expand All @@ -391,7 +389,7 @@ def exec_section_edge(
def exec_get_model(
foundry_root: Path,
test: str,
id: str | None,
version: int | None,
nodes: Iterable[NodeIdLike] = (),
pending: bool = False,
failing: bool = False,
Expand All @@ -400,7 +398,7 @@ def exec_get_model(
output = foundry_get_model(
foundry_root=foundry_root,
test=test,
id=id,
version=version,
nodes=nodes,
pending=pending,
failing=failing,
Expand Down Expand Up @@ -441,15 +439,12 @@ def parse(s: str) -> list[T]:
solc_to_k_args.add_argument('contract_file', type=file_path, help='Path to contract file.')
solc_to_k_args.add_argument('contract_name', type=str, help='Name of contract to generate K helpers for.')

def _parse_test_id_tuple(value: str) -> tuple[str, str | None]:
pattern = r'^([^,]+)(?:,\s*(\S+))?$'
match = re.match(pattern, value)

if match:
groups = match.groups()
return groups[0], groups[1] if groups[1] is not None else None
def _parse_test_version_tuple(value: str) -> tuple[str, int | None]:
if ':' in value:
test, version = value.split(':')
return (test, int(version))
else:
raise argparse.ArgumentTypeError("Invalid tuple format. Expected 'test, id' or 'test'")
return (value, None)

build = command_parser.add_parser(
'build',
Expand Down Expand Up @@ -494,15 +489,15 @@ def _parse_test_id_tuple(value: str) -> tuple[str, str | None]:
)
prove_args.add_argument(
'--test',
type=_parse_test_id_tuple,
type=_parse_test_version_tuple,
dest='tests',
default=[],
action='append',
help='Limit to only listed tests, ContractName.TestName',
)
prove_args.add_argument(
'--exclude-test',
type=_parse_test_id_tuple,
type=_parse_test_version_tuple,
dest='exclude_tests',
default=[],
action='append',
Expand Down
2 changes: 1 addition & 1 deletion src/kontrol/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def foundry_args(self) -> ArgumentParser:
def foundry_test_args(self) -> ArgumentParser:
args = ArgumentParser(add_help=False)
args.add_argument('test', type=str, help='Test to run')
args.add_argument('--id', type=str, default=None, required=False, help='ID of the test')
args.add_argument('--version', type=int, default=None, required=False, help='Version of the test to use')
return args

@cached_property
Expand Down
Loading

0 comments on commit 9d6dbd3

Please sign in to comment.