From ee6285d6d745b8e81407e47b5190ae9eba91c370 Mon Sep 17 00:00:00 2001 From: Leo Alt Date: Wed, 7 Jul 2021 12:31:09 +0200 Subject: [PATCH] Do not create VCs for underoverflow by default for Sol >=0.8 --- Changelog.md | 1 + docs/smtchecker.rst | 13 +- docs/using-the-compiler.rst | 3 +- libsolidity/formal/ModelCheckerSettings.cpp | 9 +- libsolidity/formal/ModelCheckerSettings.h | 3 + solc/CommandLineParser.cpp | 6 +- .../args | 1 + .../err | 16 +- .../input.sol | 0 .../model_checker_targets_all_bmc/args | 2 +- .../model_checker_targets_all_chc/args | 2 +- .../args | 0 .../err | 78 +++++++++ .../input.sol | 15 ++ .../model_checker_targets_default_bmc/args | 1 + .../model_checker_targets_default_bmc/err | 43 +++++ .../input.sol | 15 ++ .../model_checker_targets_default_chc/args | 1 + .../model_checker_targets_default_chc/err | 59 +++++++ .../input.sol | 15 ++ .../input.json | 0 .../output.json | 162 ++++++------------ .../input.json | 0 .../output.json | 150 +--------------- .../input.json | 0 .../output.json | 50 +----- test/libsolidity/SMTCheckerTest.cpp | 4 + test/libsolidity/SMTCheckerTest.h | 21 ++- 28 files changed, 341 insertions(+), 329 deletions(-) create mode 100644 test/cmdlineTests/model_checker_targets_all_all_engines/args rename test/cmdlineTests/{model_checker_targets_all => model_checker_targets_all_all_engines}/err (75%) rename test/cmdlineTests/{model_checker_targets_all => model_checker_targets_all_all_engines}/input.sol (100%) rename test/cmdlineTests/{model_checker_targets_all => model_checker_targets_default_all_engines}/args (100%) create mode 100644 test/cmdlineTests/model_checker_targets_default_all_engines/err create mode 100644 test/cmdlineTests/model_checker_targets_default_all_engines/input.sol create mode 100644 test/cmdlineTests/model_checker_targets_default_bmc/args create mode 100644 test/cmdlineTests/model_checker_targets_default_bmc/err create mode 100644 test/cmdlineTests/model_checker_targets_default_bmc/input.sol create mode 100644 test/cmdlineTests/model_checker_targets_default_chc/args create mode 100644 test/cmdlineTests/model_checker_targets_default_chc/err create mode 100644 test/cmdlineTests/model_checker_targets_default_chc/input.sol rename test/cmdlineTests/{standard_model_checker_targets_all => standard_model_checker_targets_default_all_engines}/input.json (100%) rename test/cmdlineTests/{standard_model_checker_targets_all => standard_model_checker_targets_default_all_engines}/output.json (90%) rename test/cmdlineTests/{standard_model_checker_targets_all_bmc => standard_model_checker_targets_default_bmc}/input.json (100%) rename test/cmdlineTests/{standard_model_checker_targets_all_bmc => standard_model_checker_targets_default_bmc}/output.json (70%) rename test/cmdlineTests/{standard_model_checker_targets_all_chc => standard_model_checker_targets_default_chc}/input.json (100%) rename test/cmdlineTests/{standard_model_checker_targets_all_chc => standard_model_checker_targets_default_chc}/output.json (61%) diff --git a/Changelog.md b/Changelog.md index d6bb765c5..916dbfde5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,6 +11,7 @@ Compiler Features: * Commandline Interface: option ``--pretty-json`` works also with ``--standard--json``. * SMTChecker: Unproved targets are hidden by default, and the SMTChecker only states how many unproved targets there are. They can be listed using the command line option ``--model-checker-show-unproved`` or the JSON option ``settings.modelChecker.showUnproved``. * SMTChecker: new setting to enable/disable encoding of division and modulo with slack variables. The command line option is ``--model-checker-div-mod-slacks`` and the JSON option is ``settings.modelChecker.divModWithSlacks``. + * SMTChecker: Do not check underflow and overflow by default. Bugfixes: diff --git a/docs/smtchecker.rst b/docs/smtchecker.rst index 5c42fb415..65b21a10e 100644 --- a/docs/smtchecker.rst +++ b/docs/smtchecker.rst @@ -34,6 +34,9 @@ The other verification targets that the SMTChecker checks at compile time are: - Out of bounds index access. - Insufficient funds for a transfer. +All the targets above are automatically checked by default if all engines are +enabled, except underflow and overflow for Solidity >=0.8.7. + The potential warnings that the SMTChecker reports are: - `` happens here.``. This means that the SMTChecker proved that a certain property fails. A counterexample may be given, however in complex situations it may also not show a counterexample. This result may also be a false positive in certain cases, when the SMT encoding adds abstractions for Solidity code that is either hard or impossible to express. @@ -93,8 +96,10 @@ Overflow } The contract above shows an overflow check example. -The SMTChecker will, by default, check every reachable arithmetic operation -in the contract for potential underflow and overflow. +The SMTChecker does not check underflow and overflow by default for Solidity >=0.8.7, +so we need to use the command line option ``--model-checker-targets "underflow,overflow"`` +or the JSON option ``settings.modelChecker.targets = ["underflow", "overflow"]``. +See :ref:`this section for targets configuration`. Here, it reports the following: .. code-block:: text @@ -447,6 +452,8 @@ If the SMTChecker does not manage to solve the contract properties with the defa a timeout can be given in milliseconds via the CLI option ``--model-checker-timeout