Upgrade `@openzeppelin/contracts-ethereum-package` from v2.5 (Solidity v5) to v3 (Solidity v6)

Is it safe to upgrade a live contract from v2.5 to v3 of @openzeppelin/contracts-ethereum-package?

There seems to be some changes to the structure of these contracts (a simplification of sorts). But has care been taken to not change the structure of these contracts?

For example we had a contract inherit @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Mintable.sol in the old version. I am now manually writing out that code in solidity v6 since it isn’t available in the latest zeppelin sdk contracts.

I guess I’ll only know after some testing, but I would love to have some pointers and gotchas. Or if this in not recommended etc?

Many thanks

1 Like

Hi @JasoonS,

Unfortunately it isn't safe.

:warning: Storage layout changes means that contracts can’t be upgraded from 2.5 to 3.0.

_From: https://forum.openzeppelin.com/t/openzeppelin-contracts-ethereum-package-v3-0/2852_


What do you need that isn't in OpenZeppelin Contracts 2.x?

1 Like

Thanks, with more digging I can see that now. We want to use the gas station network (GSN), and from what I have seen that is is only on solidity v6.

It isn’t the end of the world, we aren’t planning to use it for mainnet, it is for a sidechain project (Matic) we are working with. But it is unfortunate that our code base will fork if we have a v6 and a v5 solidity version of the code to maintain.

Any suggestions would be appreciated :slight_smile:

1 Like

Hi @JasoonS,

GSNv1 was included in OpenZeppelin Contracts 2.x and is Solidity 0.5. Note: you would need to run your own relayers and the OpenZeppelin GSN repositories have been deprecated.

All development on the GSN has been moved to the OpenGSN organization. They are developing GSNv2.

Your options appear to be for upgrading:

  • use OpenZeppelin Contracts 2.x with GSNv1 and Solidity 0.5
  • modify OpenZeppelin Contracts 2.x that you need to Solidity 0.6 and use GSNv2. You may need to update reserved storage gaps.

I recommend appropriate testing of the potential upgrade to check for any issues with storage layout.

1 Like

Thank you for the detailed answer, I truely appreciate it!

I will most definitely do a lot of testing, that is a given! And I think it is feasible to keep the storage in place with reserved gaps.

1 Like