Hi,
If the contracts are using openzeppelin-contracts-upgradeable library, would it be safe to upgrade from 3.4.0 to 4.0.0? Is the new AccessControl contract upgrade safe?
Thanks, Dmitri
Hi,
If the contracts are using openzeppelin-contracts-upgradeable library, would it be safe to upgrade from 3.4.0 to 4.0.0? Is the new AccessControl contract upgrade safe?
Thanks, Dmitri
Hi @tsudmi,
Unfortunately it isn't safe.
_From: https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/master/README.md_:
There will be storage incompatibilities across major versions of this package, which makes it unsafe to upgrade a deployed contract from one major version to another, for example from 3.4.0 to 4.0.0.
Similarly, it is not safe to upgrade from
@openzeppelin/contracts-ethereum-package(a similar previous package) to@openzeppelin/contracts-upgradeable.It is strongly encouraged to use these contracts together with a tool that can automatically guarantee the safety of an upgradeable contract, such as the OpenZeppelin Upgrades Plugins.
Thanks @abcoathup for pointing that out.
What if to upgrade only the contracts that openzeppelin-upgrades library is not complaining about?
Could that work? Removal of SafeMath and gas optimizations in 4.0.0 are too attractive to not to try that 
Hi @tsudmi,
It depends what your contract has dependencies on.
Some of the gas optimizations are about not including state.
Please note that OpenZeppelin Contracts 4.0 is still in Beta.
Can you share what your imports are?
Hi @abcoathup ,
Sure, here is the list of used imports:
@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol
@openzeppelin/contracts-upgradeable/proxy/Initializable.sol
@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol
@openzeppelin/contracts-upgradeable/utils/SafeCastUpgradeable.sol
@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol
@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol
@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol
AccessControl was changed to be more lightweight in a way that makes the storage not compatible with previous versions.
Hey @frangio , thank you for the reply.
Is AccessControlEnumerable following the old storage structure or it has also changed?
What about other contracts? Did any other from the list above has changed its storage layout?
Thanks, Dmitri
It has changed in order to make the split of AccessControl and AccessControlEnumerable possible.
Unfortunately these gas optimizations are tightly related to changing the structure of storage so it's going to be next to impossible to upgrade from 3.x to 4.x.