Hi, using OZ for a while now and I notice in new version of upgradable contracts __gap variable is removed and instead I see you are using struct which is holding storage variables. Struct slot position I see it is determined manually like below. Is below approach removing the need for __gap altogether. I have few custom base contract in inheritance chain. Should I use also same approach to determine slot positions. I am afraid if I use __gap and your ERC20Upgradable due to different approaches to slot allocation I could run into collision. I would appreciate your insight on the topic.
Thank you.
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00;
OpenZeppelin Contracts v5 uses namespaced storage according to ERC-7201. For your own contracts, you can use either regular variables with storage gaps, or namespaced storage. See Must a child contract use the namespaced storage pattern
1 Like
Thank you on your reply. Just follow up question. I read on few blogs forums transparent proxy pattern is more secure comparing to uups, but on other hand seems uups is prefered method to implement proxy as seems more gas efficient. Is it true that transparent is more secure?
Is it true that transparent is more secure?
I don't think that is generally true. They have different mechanisms for restricting upgrades, and this logic is part of your implementation contract for UUPS. So for UUPS, you would need to properly restrict upgrades in your implementation source code, but this also allows it to be more flexible in how you do so.