Have read the information about __gaps variable:
A few questions:
If a Test contract is inheriting ERC1155PresetMinterPauserUpgradeable and has also varibales that use contract storage, does the Test contract also need to implement
uint256[50] private __gap;
The Documentation states:
The size of the
__gap
array is calculated so that the amount of storage used by a contract always adds up to the same number (in this case 50 storage slots).
How is that calculated and if the Test contract has also the __gap variable, is updated with Test2 and new storage variables (example: 2 variables are added). Would be the new implementation of Test2 have: uint256[48] private __gap;
Environment
@openzeppelin/contracts-upgradeableā: ā^4.1.0
Details
Code to reproduce
contract Base {
uint256 val1;
uint256[50] private ______gap;
}
contract Child is Base {
uint256 cval1;
uint256[50] private ______gap;
}
Then at some point we decide to upgrade Child to ChildV2
contract ChildV2 is Base {
uint256 cval1;
string cval2;
uint256 cval3;
uint256[48] private ______gap;
}