Skip to content

Moving to cvc5 and fixing it up #50

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 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Available options:
60000)
--max-iterations INTEGER Number of times we may revisit a particular branching
point
--solver TEXT Used SMT solver: z3 (default) or cvc4
--solver TEXT Used SMT solver: z3 (default) or cvc5
--smtdebug Print smt queries sent to the solver
--assertions [WORD256] Comma seperated list of solc panic codes to check for
(default: everything except arithmetic overflow)
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
inherit secp256k1;
})
[
(haskell.lib.compose.addTestToolDepends [ solc z3 cvc4 ])
(haskell.lib.compose.addTestToolDepends [ solc z3 cvc5 ])
(haskell.lib.compose.appendConfigureFlags (
[ "--ghc-option=-O2" ]
++ lib.optionals stdenv.isLinux [
Expand Down Expand Up @@ -75,7 +75,7 @@
packages = _: [ hevm ];
buildInputs = [
z3
cvc4
cvc5
solc
haskellPackages.cabal-install
haskellPackages.haskell-language-server
Expand Down
4 changes: 2 additions & 2 deletions nix/hevm-tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ let
in
pkgs.recurseIntoAttrs {
yulEquivalence-z3 = runWithSolver ./yul-equivalence.nix "z3";
yulEquivalence-cvc4 = runWithSolver ./yul-equivalence.nix "cvc4";
yulEquivalence-cvc5 = runWithSolver ./yul-equivalence.nix "cvc5";

# z3 takes 3hrs to run these tests on a fast machine, and even then ~180 timeout
#smtChecker-z3 = runWithSolver ./smt-checker.nix "z3";
smtChecker-cvc4 = runWithSolver ./smt-checker.nix "cvc4";
smtChecker-cvc5 = runWithSolver ./smt-checker.nix "cvc5";
}
8 changes: 4 additions & 4 deletions src/hevm/hevm-cli/hevm-cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ data Command w
, showTree :: w ::: Bool <?> "Print branches explored in tree view"
, smttimeout :: w ::: Maybe Integer <?> "Timeout given to SMT solver in milliseconds (default: 60000)"
, maxIterations :: w ::: Maybe Integer <?> "Number of times we may revisit a particular branching point"
, solver :: w ::: Maybe Text <?> "Used SMT solver: z3 (default) or cvc4"
, solver :: w ::: Maybe Text <?> "Used SMT solver: z3 (default) or cvc5"
, smtdebug :: w ::: Bool <?> "Print smt queries sent to the solver"
, assertions :: w ::: Maybe [Word256] <?> "Comma seperated list of solc panic codes to check for (default: everything except arithmetic overflow)"
, askSmtIterations :: w ::: Maybe Integer <?> "Number of times we may revisit a particular branching point before we consult the smt solver to check reachability (default: 5)"
Expand All @@ -132,7 +132,7 @@ data Command w
, sig :: w ::: Maybe Text <?> "Signature of types to decode / encode"
, smttimeout :: w ::: Maybe Integer <?> "Timeout given to SMT solver in milliseconds (default: 60000)"
, maxIterations :: w ::: Maybe Integer <?> "Number of times we may revisit a particular branching point"
, solver :: w ::: Maybe Text <?> "Used SMT solver: z3 (default) or cvc4"
, solver :: w ::: Maybe Text <?> "Used SMT solver: z3 (default) or cvc5"
, smtoutput :: w ::: Bool <?> "Print verbose smt output"
, smtdebug :: w ::: Bool <?> "Print smt queries sent to the solver"
, askSmtIterations :: w ::: Maybe Integer <?> "Number of times we may revisit a particular branching point before we consult the smt solver to check reachability (default: 5)"
Expand Down Expand Up @@ -182,7 +182,7 @@ data Command w
, cache :: w ::: Maybe String <?> "Path to rpc cache repository"
, match :: w ::: Maybe String <?> "Test case filter - only run methods matching regex"
, covMatch :: w ::: Maybe String <?> "Coverage filter - only print coverage for files matching regex"
, solver :: w ::: Maybe Text <?> "Used SMT solver: z3 (default) or cvc4"
, solver :: w ::: Maybe Text <?> "Used SMT solver: z3 (default) or cvc5"
, smtdebug :: w ::: Bool <?> "Print smt queries sent to the solver"
, ffi :: w ::: Bool <?> "Allow the usage of the hevm.ffi() cheatcode (WARNING: this allows test authors to execute arbitrary code on your machine)"
, smttimeout :: w ::: Maybe Integer <?> "Timeout given to SMT solver in milliseconds (default: 60000)"
Expand Down Expand Up @@ -439,7 +439,7 @@ getSrcInfo cmd =

-- Although it is tempting to fully abstract calldata and give any hints about
-- the nature of the signature doing so results in significant time spent in
-- consulting z3 about rather trivial matters. But with cvc4 it is quite
-- consulting z3 about rather trivial matters. But with cvc5 it is quite
-- pleasant!

-- If function signatures are known, they should always be given for best results.
Expand Down
9 changes: 3 additions & 6 deletions src/hevm/src/EVM/SMT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,9 @@ prelude = SMT2 . fmap (T.drop 2) . T.lines $ [i|
(declare-const abstractStore Storage)
(define-const emptyStore Storage ((as const Storage) ((as const (Array (_ BitVec 256) (_ BitVec 256))) #x0000000000000000000000000000000000000000000000000000000000000000)))

(define-fun sstore ((addr Word) (key Word) (val Word) (storage Storage)) Storage (
store storage addr (store (select storage addr) key val)))
(define-fun sstore ((addr Word) (key Word) (val Word) (storage Storage)) Storage (store storage addr (store (select storage addr) key val)))

(define-fun sload ((addr Word) (key Word) (storage Storage)) Word (
select (select storage addr) key))
(define-fun sload ((addr Word) (key Word) (storage Storage)) Word (select (select storage addr) key))
|]

declareBufs :: [Text] -> SMT2
Expand Down Expand Up @@ -718,8 +716,7 @@ solverArgs = \case
[ "-in" ]
CVC5 ->
[ "--lang=smt"
, "--interactive"
, "--no-interactive-prompt"
, "--no-interactive"
, "--produce-models"
]
Custom _ -> []
Expand Down