⚡️ Memory safe assembly#333
Conversation
src/utils/SSTORE2.sol
Outdated
| uint256 size | ||
| ) private view returns (bytes memory data) { | ||
| assembly { | ||
| assembly ("memory-safe") { |
There was a problem hiding this comment.
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.
Yes, that's correct, but shouldn't affect memory-safe?
There was a problem hiding this comment.
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.