-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix uncaught exception when using empty string for yul optimization flags #14967
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bugfixes need changlog entries :)
I am wondering whether we should have a better error message for this case. Although the docs explain what should be an empty optimizer sequence, it can be a bit confusing. Or in other words, it is understandable mistake to think that an empty or blank string is the same as the empty sequence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add CLI tests as well?
75c147c
to
fce74bf
Compare
test/cmdlineTests/yul_optimizer_steps_without_optimize_blank_string/args
Outdated
Show resolved
Hide resolved
ae61ea6
to
f966433
Compare
f966433
to
831d5b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please add a short line to describe what an empty optimizer sequence is (:) here.
test/solc/CommandLineInterface.cpp
Outdated
BOOST_CHECK_EXCEPTION( | ||
parseCommandLineAndReadInputFiles({ | ||
"solc", | ||
"--strict-assembly", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"--strict-assembly", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would actually not hurt to test both as long as it can be done concisely, e.g. by looping over
{
["--strict-assembly", "--yul-optimizations="],
["--strict-assembly", "--yul-optimizations= "],
["--yul-optimizations="],
["--yul-optimizations= "],
}
which would be used to construct the command. Both assembling and compilation go through the same path in command-line parser now, but it's not guaranteed that it will always be like this and the issue affects both.
I'd say it's optional, but @nikola-matic has a point that currently you're assembling with input file called input.sol
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this should had been input.yul
. I was testing using the example from the issue.
I will add the variations.
test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_no_yul_blank_spaces/input.json
Outdated
Show resolved
Hide resolved
test/solc/CommandLineInterface.cpp
Outdated
BOOST_CHECK_EXCEPTION( | ||
parseCommandLineAndReadInputFiles({ | ||
"solc", | ||
"--strict-assembly", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would actually not hurt to test both as long as it can be done concisely, e.g. by looping over
{
["--strict-assembly", "--yul-optimizations="],
["--strict-assembly", "--yul-optimizations= "],
["--yul-optimizations="],
["--yul-optimizations= "],
}
which would be used to construct the command. Both assembling and compilation go through the same path in command-line parser now, but it's not guaranteed that it will always be like this and the issue affects both.
I'd say it's optional, but @nikola-matic has a point that currently you're assembling with input file called input.sol
.
3a47bfa
to
c60dd99
Compare
{ | ||
"C": | ||
{ | ||
"metadata": "{\"compiler\":{\"version\":\"<VERSION REMOVED>\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"A\":\"C\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"details\":{\"constantOptimizer\":false,\"cse\":false,\"deduplicate\":false,\"inliner\":false,\"jumpdestRemover\":true,\"orderLiterals\":false,\"peephole\":true,\"simpleCounterForLoopUncheckedIncrement\":true,\"yul\":false,\"yulDetails\":{\"optimizerSteps\":\":\"}},\"runs\":200},\"remappings\":[]},\"sources\":{\"A\":{\"keccak256\":\"0xb63d3c030f127aecaa7a1e223e41ef58ce5b4404939d397ccfd9ca0eb11d757b\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://567242af52de5d6870167f16a7f46d7bf27fb2b101cf99fd9ab48c645dfe7ecd\",\"dweb:/ipfs/QmamT3HqCmEbVvWwQiYSfUZRn5XwHRRkEe29BpbEJadxDT\"]}},\"version\":1}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed here that the metadata was not preserved. The optimizerSteps
value is just the colon instead of a whitespace before it and two whitespaces after it.
The cause is
solidity/libsolidity/interface/CompilerStack.cpp
Line 1732 in ae9bcab
details["yulDetails"]["optimizerSteps"] = ":"; |
being defined if the sequence is the empty optimizer sequence, although we accept whitespaces and linebreaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed that in a455829.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. But changing it so that this is preserved also technically changes the metadata so I'd keep it out of this PR.
Like I said in #14967 (comment), this is fine to do, but I'd rather do any such changes explicitly, in a separate PR.
Also, I think that the right way to make it consistent is to be always stripping whitespace from the sequence, means we'd leave this bit as is and instead change the rest to match :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will separate this commit apart.
458c093
to
d29d7eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing that still needs to be addressed is #14967 (comment). Other than that there are no big problems and I pushed some fixups to clean up some of the smaller ones without going through extra review rounds.
ac9bf2e
to
b1797fc
Compare
Rebased and squashed commits. |
Push docs and I'll re-approve so we can merge. |
Sorry, I missed that when checking pending comments. Fixed. |
929204f
to
dd6e098
Compare
dd6e098
to
a0e1a3e
Compare
fix #14946.