Hello,
I deployed an upgrade to a contract via defender propose upgrade. The only changes where adding a new mapping(address => bool) private
and I also changed some modifier
to use private functions.
- is there a way to get the state back?
- how did this happen so it doesn't happen again? I assume it has something to do with the storage layout.
The Solidity compiler assigns storage slots to the contract variables in the order it finds them (refer to the solidity docs for more info). This means that contract variables can only be appended, otherwise the contract will try to read/write the wrong storage slot.
The state is probably still there (unless you executed a method that makes changes to the storage)
1 Like
If you used defender.proposeUpgrade
from the Hardhat Upgrades plugin, it validated that your contract is upgrade safe and would have given an error if there were storage layout conflicts.
Can you ensure that you are looking at the proxy address, not the implementation address?
Yes, I used defender.proposeUpgrade
and yes I am looking at the proxy address not the implementation address.
Can you describe your process? Have you already approved and executed the proposal in Defender Admin (e.g. this step in the tutorial)?
Yes I have already approved and executed the proposal.
The first step in all of this was that I was getting an error creating a proposal saying the implementation address could not be found. So I deployed it locally and copied the impl part to my 80001 file. After that I was able to create a proposal and execute it, which I did multiple times without issue. Then I updated my contract and added a new variable mapping(address => bool) private
and then re-ran the deploy proposal. We then approved the deploy and executed it. After it was executed we no longer see any state on the contract.
https://defender.openzeppelin.com/#/admin/contracts/mumbai-0x703D76a532ba566Faf56554275380bfcf22AD844
contract address: 0x703D76a532ba566Faf56554275380bfcf22AD844 (transparent proxy)
Would it be possible if you could verify both the old and new implementation contracts on PolygonScan so that we can take a look at the differences?
Can you try running a local test similar to https://docs.openzeppelin.com/upgrades-plugins/1.x/hardhat-upgrades#proxies-tests using the Hardhat Upgrades plugin, to see if the state is maintained after the upgrade?