Skip to content

Add foundry-merge-nodes option #1934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 85 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
6decda9
Add foundry-merge-nodes option
nwatson22 Jun 30, 2023
ab52b3a
Set Version: 1.0.225
rv-auditor Jun 30, 2023
3263a14
Anti-unify without disjunct
nwatson22 Jun 30, 2023
30bbe7c
Merge branch 'noah/merge-branches' of https://github.com/runtimeverif…
nwatson22 Jun 30, 2023
46ed058
Update kevm-pyk/src/kevm_pyk/foundry.py
nwatson22 Jun 30, 2023
554a5b9
Update kevm-pyk/src/kevm_pyk/foundry.py
nwatson22 Jun 30, 2023
7b4fd9d
Fix formatting
nwatson22 Jun 30, 2023
62c2f5d
Rename apr_proof to proof, reduce whitespace
nwatson22 Jun 30, 2023
7ea8281
Disallow merging nodes if they do not match on <k>, <program>, <pc>, …
nwatson22 Jun 30, 2023
dfcc2c2
Improve variable naming
nwatson22 Jun 30, 2023
1c7105d
Add test for branch merging
nwatson22 Jun 30, 2023
2b39df6
Update expected contracts.k
nwatson22 Jul 3, 2023
5528a10
Set Version: 1.0.226
rv-auditor Jul 3, 2023
2ce28d4
Merge branch 'master' into noah/merge-branches
nwatson22 Jul 3, 2023
ce4755d
Set Version: 1.0.226
rv-auditor Jul 3, 2023
97af09f
Update expected output
nwatson22 Jul 3, 2023
94fcacf
Merge branch 'noah/merge-branches' of https://github.com/runtimeverif…
nwatson22 Jul 3, 2023
2f3db2d
Merge branch 'master' into noah/merge-branches
nwatson22 Jul 3, 2023
9e09ba9
Set Version: 1.0.227
rv-auditor Jul 3, 2023
bc19fbc
Update test_foundry_fail expected files
nwatson22 Jul 3, 2023
a7e1c9f
Merge branch 'noah/merge-branches' of https://github.com/runtimeverif…
nwatson22 Jul 3, 2023
9094565
Keep disjunction of concrete values
nwatson22 Jul 4, 2023
459c246
Switch to using associated pyk branch
nwatson22 Jul 4, 2023
a842c40
Merge master into branch
nwatson22 Jul 4, 2023
0522081
Set Version: 1.0.228
rv-auditor Jul 4, 2023
5e15427
Fix foundry_get_apr_proof and foundry_step_node to be compatible with…
nwatson22 Jul 4, 2023
ba9d0cd
Merge branch 'noah/merge-branches' of https://github.com/runtimeverif…
nwatson22 Jul 4, 2023
cb7933c
Fix various commands to work with APRBMCProof
nwatson22 Jul 4, 2023
cb55234
Update kevm-pyk/src/kevm_pyk/__main__.py
nwatson22 Jul 4, 2023
63340fb
Update kevm-pyk/src/kevm_pyk/foundry.py
nwatson22 Jul 4, 2023
3e11a53
Update foundry_merge_nodes test
nwatson22 Jul 4, 2023
686a4f9
Merge branch 'noah/merge-branches' of https://github.com/runtimeverif…
nwatson22 Jul 4, 2023
dccdc1b
Fix formatting
nwatson22 Jul 5, 2023
8160217
Update expected files
nwatson22 Jul 5, 2023
96453a9
Merge branch 'master' into noah/merge-branches
nwatson22 Jul 5, 2023
1b95136
Set Version: 1.0.229
rv-auditor Jul 5, 2023
ea9d9ec
Merge master into branch, update pyk
nwatson22 Jul 7, 2023
02819a7
Set Version: 1.0.231
rv-auditor Jul 7, 2023
014824c
Merge branch 'master' into noah/merge-branches
nwatson22 Jul 10, 2023
02c6884
Set Version: 1.0.232
rv-auditor Jul 10, 2023
32edf02
Merge branch 'master' into noah/merge-branches
nwatson22 Jul 18, 2023
994fbbe
Set Version: 1.0.235
rv-auditor Jul 18, 2023
5fbe678
Merge master into branch
nwatson22 Jul 19, 2023
be24a15
Merge master into branch
nwatson22 Jul 19, 2023
fc65509
Merge master into branch
nwatson22 Jul 19, 2023
53ea9e9
Set Version: 1.0.236
rv-auditor Jul 19, 2023
eb54d76
Revert poetry.lock
nwatson22 Jul 19, 2023
58ab024
Fix setUp method execution being limited by max_iterations
nwatson22 Jul 20, 2023
f48de7c
Merge master into branch, change test_foundry_merge_nodes to use infi…
nwatson22 Jul 26, 2023
0f5d6dd
Set Version: 1.0.239
rv-auditor Jul 26, 2023
a192f0c
Merge master into branch
nwatson22 Aug 3, 2023
153886a
Set Version: 1.0.244
rv-auditor Aug 3, 2023
ef3cd86
Merge master into branch
nwatson22 Aug 8, 2023
5f99e71
Set Version: 1.0.249
rv-auditor Aug 8, 2023
12828c2
Merge master into branch
nwatson22 Aug 9, 2023
ee6cfc9
Merge branch 'noah/merge-branches' of https://github.com/runtimeverif…
nwatson22 Aug 9, 2023
f8f49cf
Set Version: 1.0.250
rv-auditor Aug 9, 2023
6222e33
Revert foundry_get_proof and foundry_get_apr_proof changes as they ha…
nwatson22 Aug 9, 2023
94b63ce
Merge branch 'noah/merge-branches' of https://github.com/runtimeverif…
nwatson22 Aug 9, 2023
42e823d
Fix foundry_list proof_data_exists call
nwatson22 Aug 9, 2023
e4c044f
Use digest, not just method name for looking up setUp method
nwatson22 Aug 9, 2023
115a6e5
Revert change to proof loading path
nwatson22 Aug 9, 2023
29673b7
Merge branch 'master' into noah/merge-branches
nwatson22 Aug 10, 2023
2d15aa7
Use foundry.get_apr_proof in foundry_merge_nodes
nwatson22 Aug 10, 2023
bb6e17b
Set Version: 1.0.251
rv-auditor Aug 10, 2023
4327c53
Use foundry.get_apr_proof in test
nwatson22 Aug 10, 2023
b59c0cc
Merge branch 'noah/merge-branches' of https://github.com/runtimeverif…
nwatson22 Aug 10, 2023
5958001
Merge branch 'master' into noah/merge-branches
nwatson22 Aug 10, 2023
9512ef2
Set Version: 1.0.252
rv-auditor Aug 10, 2023
2bda719
Merge master into branch
nwatson22 Aug 16, 2023
55276fb
Set Version: 1.0.262
rv-auditor Aug 16, 2023
beed907
Merge remote-tracking branch 'origin/master' into noah/merge-branches
nwatson22 Aug 17, 2023
a15f2e9
Use new anti_unification function
nwatson22 Aug 17, 2023
f13245d
Set Version: 1.0.263
rv-auditor Aug 17, 2023
c33157a
Merge branch 'master' into noah/merge-branches
nwatson22 Aug 17, 2023
f59ebb0
Set Version: 1.0.264
rv-auditor Aug 17, 2023
445b9d6
Include kdefinition in anti_unify call and fix test
nwatson22 Aug 17, 2023
14b4ef8
Re-add foundry-merge-nodes command
nwatson22 Aug 18, 2023
89e6598
Set Version: 1.0.265
rv-auditor Aug 18, 2023
f1cb87d
Merge branch 'master' into noah/merge-branches
nwatson22 Aug 18, 2023
bdf7cf0
Set Version: 1.0.265
rv-auditor Aug 18, 2023
2efb5f3
Merge branch 'master' into noah/merge-branches
ehildenb Aug 18, 2023
c82092a
Set Version: 1.0.266
rv-auditor Aug 18, 2023
2e7849b
Merge branch 'master' into noah/merge-branches
nwatson22 Aug 18, 2023
53b4232
Set Version: 1.0.267
rv-auditor Aug 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kevm-pyk/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 = "kevm-pyk"
version = "1.0.224"
version = "1.0.225"
description = ""
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
29 changes: 29 additions & 0 deletions kevm-pyk/src/kevm_pyk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Foundry,
foundry_kompile,
foundry_list,
foundry_merge_nodes,
foundry_node_printer,
foundry_prove,
foundry_remove_node,
Expand Down Expand Up @@ -682,6 +683,16 @@ def exec_foundry_simplify_node(
print(f'Simplified:\n{pretty_term}')


def exec_foundry_merge_nodes(
foundry_root: Path,
test: str,
nodes: Iterable[NodeIdLike],
bug_report: bool = False,
**kwargs: Any,
) -> None:
foundry_merge_nodes(foundry_root=foundry_root, nodes=nodes, test=test)


def exec_foundry_step_node(
foundry_root: Path,
test: str,
Expand Down Expand Up @@ -1030,6 +1041,24 @@ def parse(s: str) -> list[T]:
'--depth', type=int, default=1, help='How many steps to take from initial node on edge.'
)

foundry_merge_node = command_parser.add_parser(
'foundry-merge-nodes',
help='Merge multiple nodes into one branch.',
parents=[
kevm_cli_args.logging_args,
kevm_cli_args.foundry_args,
],
)
foundry_merge_node.add_argument(
'--node',
type=str,
dest='nodes',
default=[],
action='append',
help='One node to be merged.',
)
foundry_merge_node.add_argument('test', type=str, help='Merge nodes in this CFG.')

foundry_section_edge = command_parser.add_parser(
'foundry-section-edge',
help='Given an edge in the graph, cut it into sections to get intermediate nodes.',
Expand Down
36 changes: 35 additions & 1 deletion kevm-pyk/src/kevm_pyk/foundry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pathos.pools import ProcessPool # type: ignore
from pyk.cterm import CTerm
from pyk.kast.inner import KApply, KSequence, KSort, KToken, KVariable, Subst
from pyk.kast.manip import free_vars, minimize_term
from pyk.kast.manip import anti_unify_with_constraints, free_vars, minimize_term
from pyk.kast.outer import KDefinition, KFlatModule, KImport, KRequire
from pyk.kcfg import KCFG, KCFGExplore
from pyk.ktool.kompile import LLVMKompileType
Expand Down Expand Up @@ -727,6 +727,40 @@ def foundry_simplify_node(
return foundry.kevm.pretty_print(res_term, unalias=False, sort_collections=sort_collections)


def foundry_merge_nodes(
foundry_root: Path,
test: str,
nodes: Iterable[NodeIdLike],
bug_report: bool = False,
) -> None:
br = BugReport(Path(f'{test}.bug_report')) if bug_report else None
foundry = Foundry(foundry_root, bug_report=br)
apr_proofs_dir = foundry.out / 'apr_proofs'
contract_name, test_name = test.split('.')
proof_digest = foundry.proof_digest(contract_name, test_name)
apr_proof = APRProof.read_proof(proof_digest, apr_proofs_dir)

_nodes = [apr_proof.kcfg.node(int(node_id)) for node_id in nodes]

anti_unification: KInner
for i, node in enumerate(_nodes):
cterm = node.cterm
if i < 1:
anti_unification = cterm.kast
continue
anti_unification = anti_unify_with_constraints(anti_unification, cterm.kast, disjunct=False)

new_cterm = CTerm.from_kast(anti_unification)
new_node = apr_proof.kcfg.create_node(new_cterm)

for node in _nodes:
apr_proof.kcfg.create_cover(node.id, new_node.id)

apr_proof.write_proof()

print(f'Merged nodes {[int(node) for node in nodes]} into new node {new_node.id}.')


def foundry_step_node(
foundry_root: Path,
test: str,
Expand Down
1 change: 1 addition & 0 deletions kevm-pyk/src/tests/integration/test-data/foundry-prove-all
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ArithmeticTest.test_wmul_weakly_increasing_positive
AssertTest.test_assert_false
AssertTest.test_assert_true
AssertTest.test_assert_true_branch
AssertTest.test_branch_merge
AssertTest.testFail_assert_false
AssertTest.testFail_assert_true
AssertTest.testFail_expect_revert
Expand Down
2 changes: 1 addition & 1 deletion package/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kevm (1.0.224) unstable; urgency=medium
kevm (1.0.225) unstable; urgency=medium

* Initial Release.

Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.224
1.0.225
11 changes: 9 additions & 2 deletions tests/foundry/test/Simple.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import "forge-std/Test.sol";
contract AssertTest is Test {
uint y;

function setUp() public {}

function test_failing_branch(uint x) public {
assert(x >= 100);
}
Expand All @@ -27,6 +25,15 @@ contract AssertTest is Test {
assert(y <= x);
}

function test_branch_merge(uint x) public {
if (x < 10) {
y = 0;
} else {
y = 1;
}
assert(y < 2);
}

function test_assert_false() public pure {
assert(false);
}
Expand Down