# Smart contract upgradability

**URL:** <https://forum.openzeppelin.com/t/smart-contract-upgradability/27251>\
**Category:** Contracts\
**Tags:** upgrades\
**Created:** [April 5, 2022, 12:08pm UTC](https://forum.openzeppelin.com/t/smart-contract-upgradability/27251 "2022-04-05T12:08:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![novaknole](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/novaknole/32/3796_2.png) [@novaknole](https://forum.openzeppelin.com/u/novaknole)\
**Post date:** [April 5, 2022, 12:08pm UTC](https://forum.openzeppelin.com/t/smart-contract-upgradability/27251/1 "2022-04-05T12:08:25Z")

</div>

Hi @frangio

OZ has a following contract:

```auto
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    //// some code here
    uint256[45] private __gap;
}

```

Let's look at the `__gap`.

I am wondering if OZ decides to update this, how does the process look like ? Let's say OZ wants to add one more state variable in there.. So what would you do ? My idea is that you would do one more state variable below `_symbol` and make `__gap` to `uint256[44] private__gap`.

Is this the correct assumption ?

and I guess, removing the state variable in that case won't be possible even though we mightn't need `_symbol` anymore, it still needs to be there at all times.

WDYT ?

---

<div class="post-metadata">

**Author:** ![JulissaDantes](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/julissadantes/32/15410_2.png) [@JulissaDantes](https://forum.openzeppelin.com/u/JulissaDantes)\
**Post date:** [April 6, 2022, 5:59pm UTC](https://forum.openzeppelin.com/t/smart-contract-upgradability/27251/2 "2022-04-06T17:59:45Z")

</div>

You are right the gap size gets updated as you add more to the layout, and you should not delete storage variables, check the [documentation](https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps) for more detail on that.

---

<div class="post-metadata">

**Author:** ![novaknole](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/novaknole/32/3796_2.png) [@novaknole](https://forum.openzeppelin.com/u/novaknole)\
**Post date:** [April 7, 2022, 9:16am UTC](https://forum.openzeppelin.com/t/smart-contract-upgradability/27251/3 "2022-04-07T09:16:40Z")

</div>

Hi @JulissaDantes

Thanks for your answer.

So idea is that since I am writing my own contracts as upgradable which use OZ's upgradable contracts, I was thinking of doing the same thing in terms of storage layouts(`gap`) in my own contract.

So idea will be this:

```auto
contract MyOwnContract is ERC20VotesUpgradable {
     uint myValue;
     uint secondValue;
     
    // note this variable, so i am following the same way as OZ does.
     uint[48] __gap;
}

```

So in practice, if you got such information, does this way work pretty well for upgradability purposes ?

---

<div class="post-metadata">

**Author:** ![novaknole](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/novaknole/32/3796_2.png) [@novaknole](https://forum.openzeppelin.com/u/novaknole)\
**Post date:** [April 8, 2022, 4:26pm UTC](https://forum.openzeppelin.com/t/smart-contract-upgradability/27251/4 "2022-04-08T16:26:57Z")

</div>

hey @JulissaDantes

any updates about my last question ?

---

<div class="post-metadata">

**Author:** ![JulissaDantes](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/julissadantes/32/15410_2.png) [@JulissaDantes](https://forum.openzeppelin.com/u/JulissaDantes)\
**Post date:** [April 13, 2022, 1:20pm UTC](https://forum.openzeppelin.com/t/smart-contract-upgradability/27251/5 "2022-04-13T13:20:22Z")

</div>

Hi,

You are right if you are going to create your own implementation using the gap, just always make sure to remember updating the gap at any storage extension, as you did in your example.
