Problem with UUPS Proxy Upgrade: UUPSUnauthorizedCallContext Error When Using `upgradeToAndCall` in OpenZeppelin 5.0.0

The only possible recovery that I can think of might be to call your initialize function via the proxy to set yourself as the owner in the 5.0.0 storage layout (otherwise the owner is the zero address due to the different storage layouts). Then call upgradeToAndCall to revert back to the old implementation, which will go back to the 4.x.x storage layout. However, this might not work or cause some fields to be rewritten if your initializer also writes to your own storage.

But aside from the above possibility, it is likely your proxy is broken and unrecoverable.

To avoid these kinds of issues, I'd recommend the following:

  • Do not upgrade existing deployments between major versions of OpenZeppelin Contracts
  • Use the Upgrades Plugins which helps to validate storage layout compatibility
  • Test your upgrades on development networks first
  • Test your upgrades on testnets (which you have done, which is good!) and ensure everything looks proper before proceeding to mainnet
2 Likes