Skip to content

Commit df24a4e

Browse files
authored
Merge pull request #10064 from ethereum/smt_engine
Move modelCheckerSettings out of settings in StandardCompiler
2 parents 6c9db33 + b67ade5 commit df24a4e

File tree

7 files changed

+30
-16
lines changed

7 files changed

+30
-16
lines changed

Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Compiler Features:
1414
* SMTChecker: Support ``keccak256``, ``sha256``, ``ripemd160`` and ``ecrecover`` in the CHC engine.
1515
* Control Flow Graph: Print warning for non-empty functions with unnamed return parameters that are not assigned a value in all code paths.
1616
* Command Line Interface: New option ``model-checker-engine`` allows to choose a specific SMTChecker engine. Options are ``all`` (default), ``bmc``, ``chc`` and ``none``.
17-
* Standard JSON: New option ``settings.modelCheckerEngine`` allows to choose a specific SMTChecker engine. Options are ``all`` (default), ``bmc``, ``chc`` and ``none``.
17+
* Standard JSON: New option ``modelCheckerSettings.engine`` allows to choose a specific SMTChecker engine. Options are ``all`` (default), ``bmc``, ``chc`` and ``none``.
1818

1919

2020
Bugfixes:

docs/using-the-compiler.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,11 @@ Input Description
342342
"MyContract": [ "abi", "evm.bytecode.opcodes" ]
343343
}
344344
},
345+
},
346+
"modelCheckerSettings":
347+
{
345348
// Choose which model checker engine to use: all (default), bmc, chc, none.
346-
"modelCheckerEngine": "chc"
349+
"engine": "chc"
347350
}
348351
}
349352

libsolidity/interface/StandardCompiler.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ std::optional<Json::Value> checkKeys(Json::Value const& _input, set<string> cons
396396

397397
std::optional<Json::Value> checkRootKeys(Json::Value const& _input)
398398
{
399-
static set<string> keys{"auxiliaryInput", "language", "settings", "sources"};
399+
static set<string> keys{"auxiliaryInput", "language", "modelCheckerSettings", "settings", "sources"};
400400
return checkKeys(_input, keys, "root");
401401
}
402402

@@ -414,10 +414,16 @@ std::optional<Json::Value> checkAuxiliaryInputKeys(Json::Value const& _input)
414414

415415
std::optional<Json::Value> checkSettingsKeys(Json::Value const& _input)
416416
{
417-
static set<string> keys{"parserErrorRecovery", "debug", "evmVersion", "libraries", "metadata", "optimizer", "outputSelection", "remappings", "stopAfter", "modelCheckerEngine"};
417+
static set<string> keys{"parserErrorRecovery", "debug", "evmVersion", "libraries", "metadata", "optimizer", "outputSelection", "remappings", "stopAfter"};
418418
return checkKeys(_input, keys, "settings");
419419
}
420420

421+
std::optional<Json::Value> checkModelCheckerSettingsKeys(Json::Value const& _input)
422+
{
423+
static set<string> keys{"engine"};
424+
return checkKeys(_input, keys, "modelCheckerSettings");
425+
}
426+
421427
std::optional<Json::Value> checkOptimizerKeys(Json::Value const& _input)
422428
{
423429
static set<string> keys{"details", "enabled", "runs"};
@@ -867,11 +873,16 @@ std::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompiler:
867873
"Requested output selection conflicts with \"settings.stopAfter\"."
868874
);
869875

870-
if (settings.isMember("modelCheckerEngine"))
876+
Json::Value const& modelCheckerSettings = _input.get("modelCheckerSettings", Json::Value());
877+
878+
if (auto result = checkModelCheckerSettingsKeys(modelCheckerSettings))
879+
return *result;
880+
881+
if (modelCheckerSettings.isMember("engine"))
871882
{
872-
if (!settings["modelCheckerEngine"].isString())
873-
return formatFatalError("JSONError", "modelCheckerEngine must be a string.");
874-
std::optional<ModelCheckerEngine> engine = ModelCheckerEngine::fromString(settings["modelCheckerEngine"].asString());
883+
if (!modelCheckerSettings["engine"].isString())
884+
return formatFatalError("JSONError", "modelCheckerSettings.engine must be a string.");
885+
std::optional<ModelCheckerEngine> engine = ModelCheckerEngine::fromString(modelCheckerSettings["engine"].asString());
875886
if (!engine)
876887
return formatFatalError("JSONError", "Invalid model checker engine requested.");
877888
ret.modelCheckerEngine = *engine;

test/cmdlineTests/standard_model_checker_engine_all/input.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0;\npragma experimental SMTChecker;\ncontract C { function f(uint x) public pure { assert(x > 0); } }"
88
}
99
},
10-
"settings":
10+
"modelCheckerSettings":
1111
{
12-
"modelCheckerEngine": "all"
12+
"engine": "all"
1313
}
1414
}

test/cmdlineTests/standard_model_checker_engine_bmc/input.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0;\npragma experimental SMTChecker;\ncontract C { function f(uint x) public pure { assert(x > 0); } }"
88
}
99
},
10-
"settings":
10+
"modelCheckerSettings":
1111
{
12-
"modelCheckerEngine": "bmc"
12+
"engine": "bmc"
1313
}
1414
}

test/cmdlineTests/standard_model_checker_engine_chc/input.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0;\npragma experimental SMTChecker;\ncontract C { function f(uint x) public pure { assert(x > 0); } }"
88
}
99
},
10-
"settings":
10+
"modelCheckerSettings":
1111
{
12-
"modelCheckerEngine": "chc"
12+
"engine": "chc"
1313
}
1414
}

test/cmdlineTests/standard_model_checker_engine_none/input.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0;\npragma experimental SMTChecker;\ncontract C { function f(uint x) public pure { assert(x > 0); } }"
88
}
99
},
10-
"settings":
10+
"modelCheckerSettings":
1111
{
12-
"modelCheckerEngine": "none"
12+
"engine": "none"
1313
}
1414
}

0 commit comments

Comments
 (0)