-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: ernestognw <[email protected]> Co-authored-by: Hadrien Croubois <[email protected]>
- Loading branch information
1 parent
ad27fb6
commit d398d68
Showing
5 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'openzeppelin-solidity': patch | ||
--- | ||
|
||
`Create2`, `Clones`: Mask `computeAddress` and `cloneDeterministic` outputs to produce a clean value for an `address` type (i.e. only use 20 bytes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; | ||
|
||
contract ClonesTest is Test { | ||
function testPredictDeterministicAddressSpillage(address implementation, bytes32 salt) public { | ||
address predicted = Clones.predictDeterministicAddress(implementation, salt); | ||
bytes32 spillage; | ||
/// @solidity memory-safe-assembly | ||
assembly { | ||
spillage := and(predicted, 0xffffffffffffffffffffffff0000000000000000000000000000000000000000) | ||
} | ||
assertEq(spillage, bytes32(0)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; | ||
|
||
contract Create2Test is Test { | ||
function testComputeAddressSpillage(bytes32 salt, bytes32 bytecodeHash, address deployer) public { | ||
address predicted = Create2.computeAddress(salt, bytecodeHash, deployer); | ||
bytes32 spillage; | ||
/// @solidity memory-safe-assembly | ||
assembly { | ||
spillage := and(predicted, 0xffffffffffffffffffffffff0000000000000000000000000000000000000000) | ||
} | ||
assertEq(spillage, bytes32(0)); | ||
} | ||
} |