I upgraded my FleetRegistry proxy on a local hardhat node. V1 had 37 devices registered. I deployed the V2 implementation with scripts/upgrade.js and called upgradeToAndCall(implAddr, "0x") on the proxy.
After the upgrade:
deviceCount()on the proxy returns 0devices(id)still returns the old entries, so the mapping survivedregistrationFee()returns 37, but nobody ever set a fee, soregisterDevicenow wants 37 wei
First I thought the empty-data upgradeToAndCall reset something in the proxy. Then I thought the manifest in .openzeppelin/ was stale, so I deleted it. Nothing changed.
I don't understand why one counter went to zero while the other data is fine.
State variables, V1:
mapping(bytes32 => Device) public devices;
uint32 public minFwVersion;
uint256 public deviceCount;
V2:
mapping(bytes32 => Device) public devices;
uint32 public minFwVersion;
uint256 public registrationFee; // new in V2, kept next to the other config
uint256 public deviceCount;
The upgrade script does not call upgrades.validateUpgrade. My comment there says UUPS already rejects a bad implementation via proxiableUUID.
Functions are the same except for the fee check. Solidity 0.8.24, OpenZeppelin upgradeable contracts, hardhat-upgrades plugin installed.
Is the problem in my V2 contract or in how I upgrade? I can't run the project right now, so I only describe what I saw.