Unfortunately, when I try to run the hardhat upgradeProxy() function, I receive the following error:
StorageUpgradeErrors: New storage layout is incompatible
@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:211: Upgraded `__gap` to an incompatible type
- Bad storage gap resize from 49 to 50
Size cannot increase
Generally, my code works (I have used it in several deployments for months now).
It's just the upgrade of this particular contract that is not working.
Any chance that I can perform this upgrade or is this an edge case where upgrading is generally not possible.
Please share the rest of that contract, or by the least - the global (storage) variables in it, since the error-message clearly points to the contract's storage layout as the source of the problem.
Right so the problem is that currently in your storage layout you have the registryAddress and collectionAddress variables, and by inserting ERC2771ContextUpgradeable those variables are getting shifted in the layout.
The way that you can solve this is by putting the storage in its own contract and arranging the contract like this: