In an upgradeable contract, if both the parent contract UpgradeableStorage and the child contract CapitalPoolStorage define a storage variable named __gap and their sizes are different, this will cause storage layout conflicts and potential problems.
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/storage/UpgradeableStorage.sol#L12-L22
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/storage/CapitalPoolStorage.sol#L12-L18
forge inspect CapitalPoolStorage storage-layout
If a child contract redefines a __gap variable and a __gap variable already exists in the parent contract, this may cause storage conflicts.
https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps
The __gap variable in the parent contract occupies a specific storage slot.
The __gap variable in the child contract continues to occupy a new storage slot.
This duplicate definition may cause overlapping or conflicts in storage slots, especially when the contract is upgraded.
Manual review
To avoid these issues, ensure that the __gap variable is only defined in the parent contract and not redefined in the child contract. This way, the storage layout remains consistent and predictable, allowing for safe upgrades.
DeliveryPlaceStorage, PerMarketsStorage, SystemConfigStorage, TokenManagerStorage are the same.
By following this approach, you can ensure that the storage layout remains consistent, preventing storage conflicts and ensuring the safe upgradeability of your contracts.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.