-
Notifications
You must be signed in to change notification settings - Fork 662
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
⚡️ Memory safe assembly #333
Conversation
src/utils/SSTORE2.sol
Outdated
@@ -79,7 +79,7 @@ library SSTORE2 { | |||
uint256 start, | |||
uint256 size | |||
) private view returns (bytes memory data) { | |||
assembly { | |||
assembly ("memory-safe") { |
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.
There can be dirty values at the end of the bytes btw.
Need to clean the last memory chunk here.
Take size to be 31 and have all the memory to be dirty. The last bit of the data
would be dirty.
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.
Yes, that's correct, but shouldn't affect memory-safe
?
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.
Yeah. This is independently of memory safe. I'll separate it into a new issue.
@transmissions11 ready for review, will squash once we get closer to merging. |
isn't this |
Good point, can change to that. Hmm, actually wonder how compatible that is given it starts with Btw, the |
@transmissions11 what is the earliest 0.8.x version do you want to support? There should be a CI run for that version, just to be sure. |
This is a good point, ideally 0.8.0 itself. I'll open an issue. |
Description
Mark assembly blocks
memory-safe
, so that they can be used with optimizer stages (for example the stack-to-memory elevation). See https://docs.soliditylang.org/en/v0.8.17/assembly.html?highlight=memory-safe#memory-safety for details.I did spend quite some time manually reviewing each case in this codebase, but I don't feel confident merging this without at least 2 proper reviews (cc @hrkrshnn).
Checklist
Ensure you completed all of the steps below before submitting your pull request:
forge snapshot
?npm run lint
?forge test
?Pull requests with an incomplete checklist will be thrown out.