Skip to content

Commit 0385259

Browse files
Merge pull request #205 from lefterislazar/vyper
Support for HEVM equivalence of Vyper Contracts and multiple source files.
2 parents 9938807 + c7aea38 commit 0385259

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+47532
-11078
lines changed

Makefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,19 @@ postcondition_pass=$(wildcard tests/postconditions/pass/*.act) $(typing_pass)
4242
postcondition_fail=$(wildcard tests/postconditions/fail/*.act)
4343

4444
# supposed to pass, but timeout
45-
hevm_buggy=tests/hevm/pass/transfer/transfer.act
45+
hevm_buggy=tests/hevm/pass/transfer/transfer.act tests/hevm/pass/multisource/amm/sol_vyper.json tests/hevm/pass/multisource/amm/vyper_sol.json
4646
# supposed to pass
4747
hevm_pass=$(filter-out $(hevm_buggy), $(wildcard tests/hevm/pass/*/*.act))
48+
hevm_vy_pass=$(wildcard tests/hevm/pass/vyper/*/*.act)
49+
hevm_multi_pass=$(filter-out $(hevm_buggy), $(wildcard tests/hevm/pass/multisource/*/*.json))
4850
# supposed to fail
4951
hevm_fail=$(wildcard tests/hevm/fail/*/*.act)
5052
# supposed to pass
5153
hevm_slow=tests/hevm/pass/amm/amm.act tests/hevm/pass/amm-2/amm-2.act
54+
hevm_multi_slow=$(wildcard tests/hevm/pass/multisource/amm/*.json) $(wildcard tests/hevm/pass/multisource/erc20/*.json)
5255
# supposed to pass, no slow tests
5356
hevm_fast=$(filter-out $(hevm_slow), $(hevm_pass))
57+
hevm_multi_fast=$(filter-out $(hevm_multi_slow), $(hevm_multi_pass))
5458

5559
# supposed to pass
5660
failing_typing=tests/frontend/pass/dss/vat.act tests/frontend/pass/creation/createMultiple.act tests/frontend/pass/staticstore/staticstore.act
@@ -68,8 +72,8 @@ test-parse: parser compiler $(parser_pass:=.parse.pass) $(parser_fail:=.parse.fa
6872
test-type: parser compiler $(typing_pass:=.type.pass) $(typing_fail:=.type.fail)
6973
test-invariant: parser compiler $(invariant_pass:=.invariant.pass) $(invariant_fail:=.invariant.fail)
7074
test-postcondition: parser compiler $(postcondition_pass:=.postcondition.pass) $(postcondition_fail:=.postcondition.fail)
71-
test-hevm: parser compiler $(hevm_pass:=.hevm.pass) $(hevm_fail:=.hevm.fail)
72-
test-hevm-fast: parser compiler $(hevm_fast:=.hevm.pass.fast) $(hevm_fail:=.hevm.fail)
75+
test-hevm: parser compiler $(hevm_pass:=.hevm.pass) $(hevm_vy_pass:=.hevm.vy.pass) $(hevm_multi_pass:=.hevm.multi.pass) $(hevm_fail:=.hevm.fail)
76+
test-hevm-fast: parser compiler $(hevm_fast:=.hevm.pass.fast) $(hevm_vy_pass:=.hevm.vy.pass) $(hevm_multi_fast:=.hevm.multi.pass) $(hevm_fail:=.hevm.fail)
7377
test-cabal: src/*.hs
7478
cabal v2-run test
7579

@@ -108,15 +112,22 @@ tests/%.postcondition.fail:
108112

109113
tests/hevm/pass/%.act.hevm.pass:
110114
$(eval CONTRACT := $(shell awk '/contract/{ print $$2 }' tests/hevm/pass/$*.sol))
111-
./bin/act hevm --spec tests/hevm/pass/$*.act --sol tests/hevm/pass/$*.sol --smttimeout 100000000
115+
./bin/act hevm --spec tests/hevm/pass/$*.act --sol tests/hevm/pass/$*.sol --solver bitwuzla --smttimeout 100000000
116+
117+
tests/hevm/pass/%.act.hevm.vy.pass:
118+
$(eval CONTRACT := $(shell awk '/contract/{ print $$2 }' tests/hevm/pass/$*.vy))
119+
./bin/act hevm --spec tests/hevm/pass/$*.act --vy tests/hevm/pass/$*.vy --solver bitwuzla --smttimeout 100000000
120+
121+
tests/hevm/pass/%.json.hevm.multi.pass:
122+
./bin/act hevm --sources tests/hevm/pass/$*.json --solver bitwuzla --smttimeout 100000000
112123

113124
tests/hevm/fail/%.act.hevm.fail:
114125
$(eval CONTRACT := $(shell awk '/contract/{ print $$2 }' tests/hevm/fail/$*.sol))
115-
./bin/act hevm --spec tests/hevm/fail/$*.act --sol tests/hevm/fail/$*.sol && exit 1 || echo 0
126+
./bin/act hevm --spec tests/hevm/fail/$*.act --sol tests/hevm/fail/$*.sol --solver bitwuzla && exit 1 || echo 0
116127

117128
tests/hevm/pass/%.act.hevm.pass.fast:
118129
$(eval CONTRACT := $(shell awk '/contract/{ print $$2 }' tests/hevm/pass/$*.sol))
119-
./bin/act hevm --spec tests/hevm/pass/$*.act --sol tests/hevm/pass/$*.sol --smttimeout 100000000
130+
./bin/act hevm --spec tests/hevm/pass/$*.act --sol tests/hevm/pass/$*.sol --solver bitwuzla --smttimeout 100000000
120131

121132
test-ci: test-parse test-type test-invariant test-postcondition test-coq test-hevm
122133
test: test-ci test-cabal

act.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ common common
4242
data-dword >= 0.3.2.1,
4343
prettyprinter,
4444
prettyprinter-ansi-terminal,
45+
base16,
46+
filepath
4547
if flag(ci)
4648
ghc-options: -O2 -Wall -Werror -Wno-orphans -Wno-unticked-promoted-constructors
4749
else

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
pkgs.cvc5
2828
pkgs.solc
2929
pkgs.vyper
30+
pkgs.bitwuzla
3031
];
3132
});
3233
in rec {
@@ -55,6 +56,7 @@
5556
pkgs.secp256k1
5657
pkgs.libff
5758
pkgs.vyper
59+
pkgs.bitwuzla
5860
];
5961
withHoogle = true;
6062
shellHook = ''

src/Act/Bounds.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{-# LANGUAGE GADTs #-}
22
{-# LANGUAGE DataKinds #-}
33

4-
module Act.Bounds (addBounds) where
4+
module Act.Bounds (addBounds, mkLocationBounds) where
55

66
import Data.Maybe
77
import Data.List (nub, partition)
@@ -45,14 +45,14 @@ addBoundsConstructor ctor@(Constructor _ (Interface _ decls) _ pre post invs sta
4545
invs' = addBoundsInvariant ctor <$> invs
4646
post' = post <> mkStorageBounds stateUpdates Post
4747

48-
locs = concatMap locsFromExp (pre <> post)
48+
locs = nub $ concatMap locsFromExp (pre <> post)
4949
<> concatMap locsFromInvariant invs
5050
<> concatMap locsFromUpdate stateUpdates
5151
nonlocalLocs = filter (not . isLocalLoc) locs
5252

5353
-- | Adds type bounds for calldata, environment vars, and storage vars as preconditions
5454
addBoundsBehaviour :: Behaviour -> Behaviour
55-
addBoundsBehaviour behv@(Behaviour _ _ (Interface _ decls) _ pre cases post stateUpdates _) =
55+
addBoundsBehaviour behv@(Behaviour _ _ (Interface _ decls) _ pre cases post stateUpdates ret) =
5656
behv { _preconditions = pre', _postconditions = post' }
5757
where
5858
pre' = pre
@@ -63,8 +63,9 @@ addBoundsBehaviour behv@(Behaviour _ _ (Interface _ decls) _ pre cases post stat
6363
post' = post
6464
<> mkStorageBounds stateUpdates Post
6565

66-
locs = concatMap locsFromExp (pre <> post <> cases)
66+
locs = nub $ concatMap locsFromExp (pre <> post <> cases)
6767
<> concatMap locsFromUpdate stateUpdates
68+
<> (maybe [] locsFromTypedExp ret)
6869

6970
-- | Adds type bounds for calldata, environment vars, and storage vars
7071
addBoundsInvariant :: Constructor -> Invariant -> Invariant
@@ -112,7 +113,7 @@ mkStorageBounds refs t = concatMap mkBound refs
112113
where
113114
mkBound :: StorageUpdate -> [Exp ABoolean]
114115
mkBound (Update SInteger item _) = [mkSItemBounds t item]
115-
mkBound (Update typ item@(Item _ (PrimitiveType at) _) _) | isNothing $ flattenArrayAbiType at =
116+
mkBound (Update typ item@(Item _ (PrimitiveType at) _) _) | isJust $ flattenArrayAbiType at =
116117
maybe [] (\Refl -> mkSItemBounds t <$> expandItem item) $ testEquality (flattenSType typ) SInteger
117118
mkBound _ = []
118119

@@ -129,7 +130,7 @@ mkLocationBounds refs = concatMap mkBound refs
129130
where
130131
mkBound :: Location -> [Exp ABoolean]
131132
mkBound (Loc SInteger rk item) = [mkItemBounds rk item]
132-
mkBound (Loc typ rk item@(Item _ (PrimitiveType at) _)) | isNothing $ flattenArrayAbiType at =
133+
mkBound (Loc typ rk item@(Item _ (PrimitiveType at) _)) | isJust $ flattenArrayAbiType at =
133134
maybe [] (\Refl -> mkItemBounds rk <$> expandItem item) $ testEquality (flattenSType typ) SInteger
134135
mkBound _ = []
135136

0 commit comments

Comments
 (0)