I'm trying to upgrade proxy contracts that use an inherited storage pattern - that is, the order of the state variables cannot change.
In v2 of my implementation contract, I added a new state variable to the storage in a position that should cause a storage collision (i.e. it was not appended to the end).
And to my surprise, it did not throw any validation error.
Is there something I'm missing here? Do i need to call prepareUpgrade() with some flag to check of changes in storage layout. I looked in the docs but couldn't find anything of the sort.
Validates and deploys a new implementation contract, and returns its address.
Use this method to prepare an upgrade to be run from an admin address you
do not control directly or cannot use from Hardhat.
And I think if you want to upgrade your contract with a new implementation, here is an example:
You know what, I just tested it in a separate project and it throws the error I'm looking for. I think previously it wasn't because I wasn't versioning it properly since the changes I made are in-place (as opposed to creating a new contract).
In the tutorial, it doesn't have this issue since the first contract is called Box and the upgraded one is BoxV2. What if the upgrade was made to Box? Do you have any tips here on how to best version upgrades?