Merge pull request #11261 from ethereum/smt_choose_target

[SMTChecker] Add option to choose contracts to be analyzed
This commit is contained in:
Leonardo
2021-04-21 13:11:33 +02:00
committed by GitHub
79 changed files with 1068 additions and 24 deletions
@@ -0,0 +1 @@
--model-checker-engine all
@@ -0,0 +1,25 @@
Warning: CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
B.constructor()
B.f(0)
--> model_checker_contracts_all/input.sol:5:3:
|
5 | assert(x > 0);
| ^^^^^^^^^^^^^
Warning: CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
A.constructor()
A.g(0)
--> model_checker_contracts_all/input.sol:10:3:
|
10 | assert(y > 0);
| ^^^^^^^^^^^^^
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function f(uint x) public pure {
assert(x > 0);
}
}
contract A is B {
function g(uint y) public pure {
assert(y > 0);
}
}
@@ -0,0 +1 @@
--model-checker-engine all --model-checker-contracts model_checker_contracts_all_explicit/input.sol:B,model_checker_contracts_all_explicit/input.sol:A
@@ -0,0 +1,25 @@
Warning: CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
B.constructor()
B.f(0)
--> model_checker_contracts_all_explicit/input.sol:5:3:
|
5 | assert(x > 0);
| ^^^^^^^^^^^^^
Warning: CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
A.constructor()
A.g(0)
--> model_checker_contracts_all_explicit/input.sol:10:3:
|
10 | assert(y > 0);
| ^^^^^^^^^^^^^
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function f(uint x) public pure {
assert(x > 0);
}
}
contract A is B {
function g(uint y) public pure {
assert(y > 0);
}
}
@@ -0,0 +1 @@
--model-checker-engine all --model-checker-contracts model_checker_contracts_inexistent_contract/input.sol:
@@ -0,0 +1 @@
Invalid option for --model-checker-contracts: model_checker_contracts_inexistent_contract/input.sol:
@@ -0,0 +1 @@
1
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function f(uint x) public pure {
assert(x > 0);
}
}
contract A is B {
function g(uint y) public pure {
assert(y > 0);
}
}
@@ -0,0 +1 @@
--model-checker-engine all --model-checker-contracts a.sol:
@@ -0,0 +1 @@
Invalid option for --model-checker-contracts: a.sol:
@@ -0,0 +1 @@
1
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function f(uint x) public pure {
assert(x > 0);
}
}
contract A is B {
function g(uint y) public pure {
assert(y > 0);
}
}
@@ -0,0 +1 @@
--model-checker-engine all --model-checker-contracts :A
@@ -0,0 +1 @@
Invalid option for --model-checker-contracts: :A
@@ -0,0 +1 @@
1
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function f(uint x) public pure {
assert(x > 0);
}
}
contract A is B {
function g(uint y) public pure {
assert(y > 0);
}
}
@@ -0,0 +1 @@
--model-checker-engine all --model-checker-contracts model_checker_contracts_inexistent_contract/input.sol:C
@@ -0,0 +1 @@
Warning: Requested contract "C" does not exist in source "model_checker_contracts_inexistent_contract/input.sol".
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function f(uint x) public pure {
assert(x > 0);
}
}
contract A is B {
function g(uint y) public pure {
assert(y > 0);
}
}
@@ -0,0 +1 @@
--model-checker-engine all --model-checker-contracts model_checker_contracts_inexistent_source/A.sol:A
@@ -0,0 +1 @@
Warning: Requested source "model_checker_contracts_inexistent_source/A.sol" does not exist.
@@ -0,0 +1 @@
0
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function f(uint x) public pure {
assert(x > 0);
}
}
contract A is B {
function g(uint y) public pure {
assert(y > 0);
}
}
@@ -0,0 +1 @@
--model-checker-engine all --model-checker-contracts model_checker_contracts_all_explicit/input.sol:,model_checker_contracts_all_explicit/input.sol:A
@@ -0,0 +1 @@
Invalid option for --model-checker-contracts: model_checker_contracts_all_explicit/input.sol:,model_checker_contracts_all_explicit/input.sol:A
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function f(uint x) public pure {
assert(x > 0);
}
}
contract A is B {
function g(uint y) public pure {
assert(y > 0);
}
}
@@ -0,0 +1 @@
--model-checker-engine all --model-checker-contracts model_checker_contracts_only_one/input.sol:A
@@ -0,0 +1,25 @@
Warning: CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
B.f(0)
--> model_checker_contracts_only_one/input.sol:5:3:
|
5 | assert(x > 0);
| ^^^^^^^^^^^^^
Warning: CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
A.constructor()
A.g(0)
--> model_checker_contracts_only_one/input.sol:10:3:
|
10 | assert(y > 0);
| ^^^^^^^^^^^^^
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function f(uint x) public pure {
assert(x > 0);
}
}
contract A is B {
function g(uint y) public pure {
assert(y > 0);
}
}
@@ -0,0 +1 @@
--model-checker-engine all --model-checker-contracts :C
@@ -0,0 +1 @@
Invalid option for --model-checker-contracts: :C
@@ -0,0 +1 @@
1
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function f(uint x) public pure {
assert(x > 0);
}
}
contract A is B {
function g(uint y) public pure {
assert(y > 0);
}
}
@@ -0,0 +1,28 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all"
}
}
}
@@ -0,0 +1,41 @@
{"errors":[{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
B.constructor()
B.g(0)
--> Source:5:7:
|
5 | \t\t\t\t\t\tassert(y > 0);
| \t\t\t\t\t\t^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
B.constructor()
B.g(0)","severity":"warning","sourceLocation":{"end":137,"file":"Source","start":124},"type":"Warning"},{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
A.f(0)
--> Source:10:7:
|
10 | \t\t\t\t\t\tassert(x > 0);
| \t\t\t\t\t\t^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
A.f(0)","severity":"warning","sourceLocation":{"end":231,"file":"Source","start":218},"type":"Warning"}],"sources":{"Source":{"id":0}}}
@@ -0,0 +1,32 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts":
{
"Source": ["A", "B"]
}
}
}
}
@@ -0,0 +1,41 @@
{"errors":[{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
B.constructor()
B.g(0)
--> Source:5:7:
|
5 | \t\t\t\t\t\tassert(y > 0);
| \t\t\t\t\t\t^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
B.constructor()
B.g(0)","severity":"warning","sourceLocation":{"end":137,"file":"Source","start":124},"type":"Warning"},{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
A.f(0)
--> Source:10:7:
|
10 | \t\t\t\t\t\tassert(x > 0);
| \t\t\t\t\t\t^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
A.f(0)","severity":"warning","sourceLocation":{"end":231,"file":"Source","start":218},"type":"Warning"}],"sources":{"Source":{"id":0}}}
@@ -0,0 +1,32 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts":
{
"Source": []
}
}
}
}
@@ -0,0 +1 @@
{"errors":[{"component":"general","formattedMessage":"Source contracts must be a non-empty array.","message":"Source contracts must be a non-empty array.","severity":"error","type":"JSONError"}]}
@@ -0,0 +1,32 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts":
{
"Source": [""]
}
}
}
}
@@ -0,0 +1 @@
{"errors":[{"component":"general","formattedMessage":"Contract name cannot be empty.","message":"Contract name cannot be empty.","severity":"error","type":"JSONError"}]}
@@ -0,0 +1,32 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts":
{
"": ["A"]
}
}
}
}
@@ -0,0 +1 @@
{"errors":[{"component":"general","formattedMessage":"Source name cannot be empty.","message":"Source name cannot be empty.","severity":"error","type":"JSONError"}]}
@@ -0,0 +1,32 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts":
{
"Source": ["C"]
}
}
}
}
@@ -0,0 +1,3 @@
{"errors":[{"component":"general","errorCode":"7400","formattedMessage":"Warning: Requested contract \"C\" does not exist in source \"Source\".
","message":"Requested contract \"C\" does not exist in source \"Source\".","severity":"warning","type":"Warning"}],"sources":{"Source":{"id":0}}}
@@ -0,0 +1,43 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
},
"Source2":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
import 'Source';
contract C is A {
function h(uint z) public pure {
assert(z > 100);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts":
{
"Source": ["A"], "Source2": ["C"]
}
}
}
}
@@ -0,0 +1,101 @@
{"errors":[{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
A.constructor()
B.g(0)
--> Source:5:7:
|
5 | \t\t\t\t\t\tassert(y > 0);
| \t\t\t\t\t\t^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
A.constructor()
B.g(0)","severity":"warning","sourceLocation":{"end":137,"file":"Source","start":124},"type":"Warning"},{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
A.f(0)
--> Source:10:7:
|
10 | \t\t\t\t\t\tassert(x > 0);
| \t\t\t\t\t\t^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
A.f(0)","severity":"warning","sourceLocation":{"end":231,"file":"Source","start":218},"type":"Warning"},{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
A.constructor()
B.g(0)
--> Source:5:7:
|
5 | \t\t\t\t\t\tassert(y > 0);
| \t\t\t\t\t\t^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
A.constructor()
B.g(0)","severity":"warning","sourceLocation":{"end":137,"file":"Source","start":124},"type":"Warning"},{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
A.f(0)
--> Source:10:7:
|
10 | \t\t\t\t\t\tassert(x > 0);
| \t\t\t\t\t\t^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
A.f(0)","severity":"warning","sourceLocation":{"end":231,"file":"Source","start":218},"type":"Warning"},{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
z = 0
Transaction trace:
C.constructor()
C.h(0)
--> Source2:6:7:
|
6 | \t\t\t\t\t\tassert(z > 100);
| \t\t\t\t\t\t^^^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
z = 0
Transaction trace:
C.constructor()
C.h(0)","severity":"warning","sourceLocation":{"end":165,"file":"Source2","start":150},"type":"Warning"}],"sources":{"Source":{"id":0},"Source2":{"id":1}}}
@@ -0,0 +1,32 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts":
{
"Source": ["A"]
}
}
}
}
@@ -0,0 +1,41 @@
{"errors":[{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
A.constructor()
B.g(0)
--> Source:5:7:
|
5 | \t\t\t\t\t\tassert(y > 0);
| \t\t\t\t\t\t^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
y = 0
Transaction trace:
A.constructor()
B.g(0)","severity":"warning","sourceLocation":{"end":137,"file":"Source","start":124},"type":"Warning"},{"component":"general","errorCode":"6328","formattedMessage":"Warning: CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
A.f(0)
--> Source:10:7:
|
10 | \t\t\t\t\t\tassert(x > 0);
| \t\t\t\t\t\t^^^^^^^^^^^^^
","message":"CHC: Assertion violation happens here.
Counterexample:
x = 0
Transaction trace:
A.constructor()
A.f(0)","severity":"warning","sourceLocation":{"end":231,"file":"Source","start":218},"type":"Warning"}],"sources":{"Source":{"id":0}}}
@@ -0,0 +1,32 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts":
{
"Sourceee": ["A"]
}
}
}
}
@@ -0,0 +1,3 @@
{"errors":[{"component":"general","errorCode":"9134","formattedMessage":"Warning: Requested source \"Sourceee\" does not exist.
","message":"Requested source \"Sourceee\" does not exist.","severity":"warning","type":"Warning"}],"sources":{"Source":{"id":0}}}
@@ -0,0 +1,29 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts": 2
}
}
}
@@ -0,0 +1 @@
{"errors":[{"component":"general","formattedMessage":"settings.modelChecker.contracts is not a JSON object.","message":"settings.modelChecker.contracts is not a JSON object.","severity":"error","type":"JSONError"}]}
@@ -0,0 +1,32 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts":
{
"Source": 2
}
}
}
}
@@ -0,0 +1 @@
{"errors":[{"component":"general","formattedMessage":"Source contracts must be an array.","message":"Source contracts must be an array.","severity":"error","type":"JSONError"}]}
@@ -0,0 +1,32 @@
{
"language": "Solidity",
"sources":
{
"Source":
{
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract B {
function g(uint y) public pure {
assert(y > 0);
}
}
contract A is B {
function f(uint x) public pure {
assert(x > 0);
}
}"
}
},
"settings":
{
"modelChecker":
{
"engine": "all",
"contracts":
{
"Source": [2]
}
}
}
}
@@ -0,0 +1 @@
{"errors":[{"component":"general","formattedMessage":"Every contract in settings.modelChecker.contracts must be a string.","message":"Every contract in settings.modelChecker.contracts must be a string.","severity":"error","type":"JSONError"}]}
+7 -1
View File
@@ -16,6 +16,7 @@
*/
// SPDX-License-Identifier: GPL-3.0
#include "libsolidity/formal/ModelCheckerSettings.h"
#include <test/tools/fuzzer_common.h>
#include <libsolidity/interface/CompilerStack.h>
@@ -99,7 +100,12 @@ void FuzzerUtil::testCompiler(
if (_forceSMT)
{
forceSMT(_input);
compiler.setModelCheckerSettings({frontend::ModelCheckerEngine::All(), frontend::ModelCheckerTargets::All(), /*timeout=*/1});
compiler.setModelCheckerSettings({
frontend::ModelCheckerContracts::Default(),
frontend::ModelCheckerEngine::All(),
frontend::ModelCheckerTargets::Default(),
/*timeout=*/1
});
}
compiler.setSources(_input);
compiler.setEVMVersion(evmVersion);