Upgrade add new storage variable

Can I ask a stupid question about where to put the new variable in upgrade is better or it just doesn't matter. Before gap or after gap? What's everyone's opinion and preferences?


address newVariable;
uint256[49] private __gap;


uint256[49] private __gap;
address newVariable;

:computer: Environment

Hardhat V2.6.1
pragma solidity 0.7.6;

Hi, I think for the first way, the right way should be the following:

address newVariable;
uint256[48] private __gap;   <<-- change at this line

and for the second way, it is ok if there is no others variable after __gap.

And for more details, maybe you can have a look at here: Using with Upgrades - OpenZeppelin Docs

Yes, forgot to mention 50 storage by default so changed to 49. It's just want to see what's everyone's preferences, prepend or append on the gap.

1 Like