I have a quick question about a storage-slot optimization idea.
Instead of deriving a mapping slot via keccak256(owner, slot), I’m considering using the address directly under a dedicated namespace, e.g.:
bytes32 private constant _BALANCE_SPACE_SEED = 0x87a211a2000000000000000000000000000000000000000000000000000000;
function balanceOf(address owner) public view returns (uint256 result) {
/// @solidity memory-safe-assembly
assembly {
result := sload(or(_BALANCE_SPACE_SEED, owner))
}
}
Would this be safe and correct.
Are there any risks of storage collisions or other security issues with or(_BALANCE_SPACE_SEED, owner).