The upgrade function is used repeatedly with the current version of the smart contract as an argument for the new version, but instead, a new one should be deployed

I was using a proxy, and everything was working fine, but at some point during an upgrade, the plugin started calling the upgradeTo function with the old implementation as the argument.

This makes further upgrades impossible.

It might be related to the forceImport function.

Could you please explain why this happens?

pragma solidity ^0.8.9;
contract View is UUPSUpgradeable, Initializable{}

    "@openzeppelin/contracts-upgradeable": "^4.9.6",
    "@openzeppelin/hardhat-upgrades": "^3.0.1",
    "hardhat": "^2.22.12",

    contract = await upgrades.upgradeProxy(contractAddress, contractFactory)


  const contractFactory = await ethers.getContractFactory(contractName, {
    libraries: libs,
  })

  const _ = await upgrades.forceImport(contractAddress, contractFactory)

I guess the answer might be the redeployImplementation: "always" flag.

But I’m wondering — why would I call upgrades.upgradeProxy if I don’t actually want to update anything?

It still calls upgradeTo, but with the old implementation — that’s literally doing nothing.

1 Like

If the implementation contract that you are upgrading to is detected to be the identical to one that you previously deployed, it will use the existing implementation address. See Upgrade contract without changes to storage layout - #2 by ericglau

It will always run the upgrade when you call upgrades.upgradeProxy, because:

  1. The upgrade function on the contract is expected to emit an event, and
  2. You might want to call an arbitrary function on the contract when running it