-
Notifications
You must be signed in to change notification settings - Fork 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 custom cleanup sequence missing from metadata when other optimizer settings have default values #15859
base: develop
Are you sure you want to change the base?
Conversation
This needs a changelog entry and a regression test that reproduces it. Also, pinging @kuzdogan. Sourcify may need a workaround for this. We should check which versions are affected (I guess it was introduced along with the cleanup sequence?). |
7aaf41b
to
cc03b19
Compare
The setting was introduced in v0.8.18 (including it not being part of |
8e704f5
to
c1c10ac
Compare
"yulDetails": { | ||
// default optimization sequence with a custom (truncated) cleanup sequence. | ||
// 0.8.18 - 0.8.28 this would spuriously be interpreted as defaulted optimizer settings in metadata. | ||
"optimizerSteps": "dhfoDgvulfnTUtnIf[xa[r]EscLMcCTUtTOntnfDIulLculVcul [j]Tpeulxa[rul]xa[r]cLgvifCTUca[r]LSsTFOtfDnca[r]Iulc]jmul[jul] VcTOcul jmul:D" |
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 don't like this test so much actually. We won't regress if the default sequence changes at some point and it goes unnoticed to update it here as well. Something more elaborate would be first asserting that with the correct sequence it does produce default output and then truncating it in one of these ~
-prefixed tests...
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.
Another option would be to add this case to boost-based metadata tests:
solidity/test/libsolidity/Metadata.cpp
Lines 452 to 459 in 9005353
std::vector<std::tuple<std::string, std::string>> sequences = | |
{ | |
// {"<optimizer sequence>", "<optimizer cleanup sequence>"} | |
{"", ""}, | |
{"", "fDn"}, | |
{"dhfoDgvulfnTUtnIf", "" }, | |
{"dhfoDgvulfnTUtnIf", "fDn"} | |
}; |
There you can refer to OptimiserSettings
and the default sequence without hard-coding it.
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.
Nice, yeah, much better! I had to refactor it a bit because it was testing against minimal
settings plus yul optimizations which was already caught by the old comparison operator. For the regression to kick in, I now take standard
settings and modify only the cleanup 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.
Maybe let's just make it loop over all presets (OptimisationPreset
)? This bug shows that we can't really assume that this is completely independent of other settings so this would give us a bit more coverage and also make the test more regular.
For completness, we should also have a test that non-default main sequence and default cleanup works.
We also don't really test that minimal
translates to just enabled: false
, standard
to enabled: false
and other presets to different things and we should.
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.
Increased the coverage accordingly.
"yulDetails": { | ||
// default optimization sequence with a custom (truncated) cleanup sequence. | ||
// 0.8.18 - 0.8.28 this would spuriously be interpreted as defaulted optimizer settings in metadata. | ||
"optimizerSteps": "dhfoDgvulfnTUtnIf[xa[r]EscLMcCTUtTOntnfDIulLculVcul [j]Tpeulxa[rul]xa[r]cLgvifCTUca[r]LSsTFOtfDnca[r]Iulc]jmul[jul] VcTOcul jmul:D" |
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.
Another option would be to add this case to boost-based metadata tests:
solidity/test/libsolidity/Metadata.cpp
Lines 452 to 459 in 9005353
std::vector<std::tuple<std::string, std::string>> sequences = | |
{ | |
// {"<optimizer sequence>", "<optimizer cleanup sequence>"} | |
{"", ""}, | |
{"", "fDn"}, | |
{"dhfoDgvulfnTUtnIf", "" }, | |
{"dhfoDgvulfnTUtnIf", "fDn"} | |
}; |
There you can refer to OptimiserSettings
and the default sequence without hard-coding it.
f3afc4f
to
38d9c50
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.
In terms of fixing things everything seems in order. We might want to still refactor the test a bit more to give us more coverage. See my previous comment.
38d9c50
to
db7a569
Compare
db7a569
to
ea37c3b
Compare
Extracted from PR #15834, see #15834 (comment).
The previous implementation did not make use of the
yulOptimiserCleanupSteps
. As @cameel suspected, providing a custom cleanup sequence under the default optimization sequence previously simply yielded a"optimizer": "enabled":true, "runs": 200}
which potentially (or: most likely) doesn't reproduce the original compilation results.I think it is a bit mitigated by there not being a specific field for the cleanup sequence in the standard-json input but one would rather have to reproduce the entire default optimization sequence, add a colon, and then modify the cleanup sequence.