Renaming of incompatible type

Hi,

I would like to rename the Counter variable in an upgradeable contract.
However, the storage check of upgrades plugin complains with a following error:

Replaced `nonce1` with `nonce2` of incompatible type

Contract v1

CountersUpgradeable.Counter private nonce1;

Contract v2

CountersUpgradeable.Counter private nonce2;

Is it still okay for me to proceed with an upgrade or will it break the storage layout?

1 Like

Hi @tsudmi,

Welcome to the community :wave:

Currently state variable renaming is not allowed for upgrades, in case it is an error by the user. There is an open issue for a way to safely rename state variables:

Hi @abcoathup ,

Thank you, great to be part of the community!

I’m following that issue and thought to change the variable name intentionally.
So I thought to disable the storage check for that contract and upgrade it.
Just wanted to check whether changing the variable name while keeping the same type and order wouldn’t break the layout even if its type is something not primitive like CountersUpgradeable.Counter

1 Like

Hi @tsudmi,

Only changing the name and not the type should be upgrade safe, but it is always worth including higher level tests to check that state for your contract is maintained.

If you get a chance it would be great to Introduce yourself here! and let the community know what you are building.

1 Like

thanks for the awesome information.