Sitelet https://web.archive.org/web/20201113050352/https://github.com/ethereum/solidity/pull/8926
Skip to content
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

[SMTChecker] Support to BitVector and bitwise `and` #8926

Merged
merged 1 commit into from May 27, 2020
Merged

Conversation

@leonardoalt
Copy link
Member

@leonardoalt leonardoalt commented May 13, 2020 •

Ref #9043

This PR adds the BitVectorSort which will be used for bitwise operators, and adds the bitwise and operator to test that.
For the SMTEncoder, the strategy to support bitwise operations is to convert the arguments (represented as SMT Integers) to BVs, apply the operation, then convert back to Integer. This works also for signed Integers.

The Yul constraint optimizer might want to use BVs directly.

  • z3
  • CVC4
  • smtlib2interface
@leonardoalt leonardoalt force-pushed the smt_bitwise_and branch from ffa2dfd to 9853a3a May 13, 2020
@elenadimitrova elenadimitrova added this to In progress in Solidity via automation May 14, 2020
@leonardoalt leonardoalt force-pushed the smt_bitwise_and branch from 9853a3a to 40b5b35 May 14, 2020
@leonardoalt leonardoalt force-pushed the smt_bitwise_and branch from 40b5b35 to 88482c7 May 25, 2020
Changelog.md Outdated Show resolved Hide resolved
libsolidity/formal/CHC.cpp Outdated Show resolved Hide resolved
@leonardoalt leonardoalt force-pushed the smt_bitwise_and branch from 88482c7 to f0439af May 26, 2020
@leonardoalt
Copy link
Member Author

@leonardoalt leonardoalt commented May 26, 2020

@chriseth all parts done, ready for review

@leonardoalt leonardoalt force-pushed the smt_bitwise_and branch from 6e82255 to f76156b May 26, 2020
@ethereum ethereum deleted a comment from stackenbotten May 26, 2020
@ethereum ethereum deleted a comment from stackenbotten May 26, 2020
@leonardoalt leonardoalt force-pushed the smt_bitwise_and branch 2 times, most recently from 05bdf8b to d70997e May 26, 2020
@leonardoalt
Copy link
Member Author

@leonardoalt leonardoalt commented May 26, 2020

Managed to change the CVC4 interface for int2bv and bv2int so that it compiles on both CVC4 1.6 (Ubuntu) and 1.7 (Arch)

@chriseth
Copy link
Contributor

@chriseth chriseth commented May 27, 2020

Can you check the test failure?

@leonardoalt
Copy link
Member Author

@leonardoalt leonardoalt commented May 27, 2020

Yep, checking. At least now the Ubuntu ones are ok.

@leonardoalt
Copy link
Member Author

@leonardoalt leonardoalt commented May 27, 2020

I think we need ethereum/solc-js#468 for that test to pass here

@leonardoalt
Copy link
Member Author

@leonardoalt leonardoalt commented May 27, 2020

No that doesn't really solve it...

@leonardoalt leonardoalt force-pushed the smt_bitwise_and branch from d70997e to c0e7f8f May 27, 2020
@@ -126,7 +126,7 @@ pair<CheckResult, vector<string>> SMTLib2Interface::check(vector<Expression> con
result = CheckResult::ERROR;

vector<string> values;
if (result == CheckResult::SATISFIABLE && result != CheckResult::ERROR)
if (result == CheckResult::SATISFIABLE && !_expressionsToEvaluate.empty())

This comment has been minimized.

@leonardoalt

leonardoalt May 27, 2020
Author Member

@chriseth this was apparently a bug here that caused the solc-js test failure. No model was requested in this test (it uses only literals), and because of the solver response sat\n, it was parsing an empty value which caused an assertion failure at BMC.cpp:767.

@leonardoalt leonardoalt mentioned this pull request May 27, 2020
4 of 5 tasks complete
libsmtutil/Sorts.h Outdated Show resolved Hide resolved
libsmtutil/Sorts.h Outdated Show resolved Hide resolved
return m_context.mkExpr(CVC4::kind::ITE,
m_context.mkExpr(
CVC4::kind::EQUAL,
m_context.mkExpr(CVC4::kind::BITVECTOR_EXTRACT, extractOp, arguments[0]),

This comment has been minimized.

@chriseth

chriseth May 27, 2020
Contributor

Is this tested?

This comment has been minimized.

@leonardoalt

leonardoalt May 27, 2020
Author Member

Yep, the tests also run CVC4, even different versions of it

@leonardoalt leonardoalt force-pushed the smt_bitwise_and branch from c0e7f8f to 9e9f0c5 May 27, 2020
@leonardoalt
Copy link
Member Author

@leonardoalt leonardoalt commented May 27, 2020

@chriseth updated & squashed

@chriseth chriseth merged commit 5f8299b into develop May 27, 2020
37 checks passed
37 checks passed
ci/circleci: b_archlinux Your tests passed on CircleCI!
Details
ci/circleci: b_docs Your tests passed on CircleCI!
Details
ci/circleci: b_ems Your tests passed on CircleCI!
Details
ci/circleci: b_osx Your tests passed on CircleCI!
Details
ci/circleci: b_ubu Your tests passed on CircleCI!
Details
ci/circleci: b_ubu18 Your tests passed on CircleCI!
Details
ci/circleci: b_ubu_asan Your tests passed on CircleCI!
Details
ci/circleci: b_ubu_asan_clang Your tests passed on CircleCI!
Details
ci/circleci: b_ubu_clang Your tests passed on CircleCI!
Details
ci/circleci: b_ubu_cxx20 Your tests passed on CircleCI!
Details
ci/circleci: b_ubu_ossfuzz Your tests passed on CircleCI!
Details
ci/circleci: b_ubu_release Your tests passed on CircleCI!
Details
ci/circleci: chk_antlr_grammar Your tests passed on CircleCI!
Details
ci/circleci: chk_buglist Your tests passed on CircleCI!
Details
ci/circleci: chk_coding_style Your tests passed on CircleCI!
Details
ci/circleci: chk_docs_pragma_min_version Your tests passed on CircleCI!
Details
ci/circleci: chk_errorcodes Your tests passed on CircleCI!
Details
ci/circleci: chk_proofs Your tests passed on CircleCI!
Details
ci/circleci: chk_pylint Your tests passed on CircleCI!
Details
ci/circleci: chk_spelling Your tests passed on CircleCI!
Details
ci/circleci: t_ems_compile_ext_colony Your tests passed on CircleCI!
Details
ci/circleci: t_ems_compile_ext_gnosis Your tests passed on CircleCI!
Details
ci/circleci: t_ems_compile_ext_zeppelin Your tests passed on CircleCI!
Details
ci/circleci: t_ems_solcjs Your tests passed on CircleCI!
Details
ci/circleci: t_osx_cli Your tests passed on CircleCI!
Details
ci/circleci: t_osx_soltest Your tests passed on CircleCI!
Details
ci/circleci: t_ubu_asan_cli Your tests passed on CircleCI!
Details
ci/circleci: t_ubu_asan_constantinople Your tests passed on CircleCI!
Details
ci/circleci: t_ubu_asan_constantinople_clang Your tests passed on CircleCI!
Details
ci/circleci: t_ubu_clang_soltest Your tests passed on CircleCI!
Details
ci/circleci: t_ubu_cli Your tests passed on CircleCI!
Details
ci/circleci: t_ubu_release_cli Your tests passed on CircleCI!
Details
ci/circleci: t_ubu_release_soltest Your tests passed on CircleCI!
Details
ci/circleci: t_ubu_soltest Your tests passed on CircleCI!
Details
ci/circleci: t_ubu_soltest_enforce_yul Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Solidity automation moved this from In progress to Done May 27, 2020
@chriseth chriseth deleted the smt_bitwise_and branch May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Solidity
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.