-
Notifications
You must be signed in to change notification settings - Fork 11.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
Clean dirty addresses and booleans #5195
Conversation
|
test/utils/SlotDerivation.t.sol
Outdated
@@ -10,6 +10,13 @@ import {SlotDerivation} from "@openzeppelin/contracts/utils/SlotDerivation.sol"; | |||
contract SlotDerivationTest is Test, SymTest { | |||
using SlotDerivation for bytes32; | |||
|
|||
function testDirtyAddress() public { | |||
bytes32 result1 = SlotDerivation.deriveMapping(0, address(uint160(type(uint256).max))); |
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.
This does not contain dirty upper bits. The casting to uint160
cleans 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.
only when stored in memory explicitly afaik -- https://x.com/optimizoor/status/1560590413768994816?s=46. test reverts with current master behaviour.
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, good to know. That means its actually possible to generate dirty bytes without assembly !
I changed the tests to something that is clearer IMO, and that support dirtying any type (bool, addres, anything else we want to add)
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.
Minor nit if you're eager to discuss. LGTM
Fixes M-01
PR Checklist
npx changeset add
)