To Inherit Version1 to Version2, Or to Copy Code + Inheritance Order from Version1 to Version2?

Thank you @frangio . As I can see, even in diamond storage, you would create a struct for each contract and store it in specific hash slot. If I understand correctly, even in this pattern, you wont be able to add the new variable in the middle of the struct or remove the variable from it. This pattern just helps only with the case of inheritance which is still a big step forward. Does OZ plan on that even with diamond, you would solve it so that it will be possible to even remove the variable from struct ? I would at least design my contracts with this pattern but have a feeling that removing variables and adding them in the middle is still not possible. Thoughts ?

Yes, it is not possible to remove or add from the middle of the struct, except if the variable is added in a place where there didn't use to be another variable for reasons of padding and data type sizes.

For example, if a struct contains uint8 x; uint256 y; there is likely empty space between x and y and it is safe to add a new variable uint8 x; uint8 Z; uint256 y;.

Recent versions of OpenZeppelin Upgrades Plugins accept this kind of change to variables and structs.

Amazing !!

https://github.com/GeniusVentures/openzeppelin-contracts-diamond is this how you are gonna implement as well ? I would love to follow the same principle as you(OZ)

We haven't decided the details yet. But based on what I remember from that fork I think it's not what we'll do, we will probably do a bit simpler and not have a separate contract for Storage.

1 Like