Make missing settings.optimizer.enabled key in Standard JSON equivalent to setting it to false

This commit is contained in:
Kamil Śliwak 2021-06-14 17:15:40 +02:00
parent 6b446bd46d
commit 59957b18dc
3 changed files with 10 additions and 4 deletions

View File

@ -8,7 +8,9 @@ Compiler Features:
Bugfixes:
* Control Flow Graph: Fix incorrectly reported unreachable code.
* Solc-Js: Use the same optimizer settings as ``solc`` when the ``--optimize`` flag is not specified.
* Solc-Js: When running ``solcjs`` without the ``--optimize`` flag, use ``settings.optimizer.enabled=false`` in Standard JSON instead of omitting the key.
* Standard JSON: Omitting ``settings.optimizer.enabled`` was not equivalent to setting it to ``false``.
It meant disabling also the peephole optimizer and jumpdest remover which by default still run with ``enabled=false``.

View File

@ -246,7 +246,10 @@ Input Description
"remappings": [ ":g=/dir" ],
// Optional: Optimizer settings
"optimizer": {
// disabled by default
// Disabled by default.
// NOTE: enabled=false still leaves some optimizations on. See comments below.
// WARNING: Before version 0.8.6 omitting the 'enabled' key was not equivalent to setting
// it to false and would actually disable all the optimizations.
"enabled": true,
// Optimize for how many times you intend to run the code.
// Lower values will optimize more for initial deployment cost, higher

View File

@ -558,14 +558,15 @@ std::variant<OptimiserSettings, Json::Value> parseOptimizerSettings(Json::Value
if (auto result = checkOptimizerKeys(_jsonInput))
return *result;
OptimiserSettings settings = OptimiserSettings::none();
OptimiserSettings settings = OptimiserSettings::minimal();
if (_jsonInput.isMember("enabled"))
{
if (!_jsonInput["enabled"].isBool())
return formatFatalError("JSONError", "The \"enabled\" setting must be a Boolean.");
settings = _jsonInput["enabled"].asBool() ? OptimiserSettings::standard() : OptimiserSettings::minimal();
if (_jsonInput["enabled"].asBool())
settings = OptimiserSettings::standard();
}
if (_jsonInput.isMember("runs"))