3

If we are using the initializable contract before OZ 0.5.0 for our transparent Upgradeable proxy.

It had two variables in slot 0.

uint8 private _initialized;
bool private _initializing;

Now in OZ 0.5.0 the storage alignment has been changed, including a struct and namespaces storage pattern.

   struct InitializableStorage {
       uint64 _initialized;
       bool _initializing;
   }

The problem is if we try to use the latest initializable contract for our new implementation contract, it messes up the storage layout because now slot 0 is empty, and the rest of our contract variables point to one storage less than the initially assigned slot.

What should be the solution for this:

  1. We add a variable at the top to use up slot 0 so that the rest of the variables start from their original slot.
  2. We use OZ 0.4.9 because it has the old initializable, that uses up the slot 0.

Also asked in OZ forum

1 Answer 1

0

OZ team has replied on the forum

It is NOT safe to upgrade a proxy from an implementation that uses OpenZeppelin Contracts 4.x to an implementation that uses 5.x. Version 5.x is a major version and has breaking changes, including (but not limited to) the storage layout differences that you mentioned above.

If your implementation contract is on 4.x, you can update to the latest 4.x release which at the moment is 4.9.6.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.