-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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 verbatim control flow side effects #15542
Conversation
Thank you for your contribution to the Solidity compiler! A team member will follow up shortly. If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother. If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix. |
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.
Just a nitpick. And also, @cameel mentioned a changelog entry, but I am not sure about the actual bug he referred to.
58c8cb5
to
cd1fd4f
Compare
Also not sure. Typo fix pushed. |
#15535 is merged so now we can pass these via the parameter we added there. Might also be a good idea to define a helper called |
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.
We discussed this bug on Wednesday and we do think that this may cause actual problems in the optimizer. E.g. UnusedStoreEliminator might mistakenly remove a store operation assuming that the code will revert, while a verbatim block actually makes it terminate successfully.
We need a repro test case to confirm it. I think that something like store_before_conditionally_terminating_function_call_revert.yul
should do it if you replace the conditionallyStop()
call with a verbatim block that uses RETURN
.
Still, we decided that we'll not treat it as an important bug (i.e. no blog post and no bug list entry, just a normal changelog entry), because doing something like this actually violates the prescribed usage rules for verbatim
:
- Control-flow should not jump into or out of verbatim blocks, but it can jump within the same verbatim block.
Instead, we should add a warning in verbatim
docs saying that until 0.8.28 verbatim
had this flaw. We could also clarify the point above to specifically say that reverting and returning within verbatim
are not allowed.
cd1fd4f
to
823c59d
Compare
I added such a test but even without this fix it passes. After debugging of
|
Nice. I looked at the implementation and I think you're right. So we're safe here. In that case we do not need the changelog entry or the warning. I'd still add the test case though, even if it does not fail. Best to have this corner case covered. And we should till clarify the docs to say that reverting and returning within verbatim are not allowed. |
Test added. Doc edited. |
be705e8
to
5bf273c
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.
Looks good, but I have two small suggestions.
.../libyul/yulOptimizerTests/unusedStoreEliminator/store_before_terminating_verbatim_revert.yul
Show resolved
Hide resolved
5bf273c
to
c23c213
Compare
c23c213
to
1b3d549
Compare
ControlFlowSideEffects
parameter tocreateFunction
in EVMDialect #15535 (comment)