Error: Contract is not upgrade safe. Use of delegatecall is not allowed

Hi!

I am trying to test deployment through a proxy.
My contract does not have any delegate calls, neither selfdestruct.
However, after

upgrades.deployProxy(MyContract)

I'm getting an error that I can remove using { unsafeAllow: ['delegatecall'] }

However, something tells me there is unsafe stuff happening here.

Error: Contract `MyContract` is not upgrade safe
@openzeppelin/contracts/utils/Address.sol:185: Use of delegatecall is not allowed
    https://zpl.in/upgrades/error-002
      at Object.assertUpgradeSafe (node_modules/@openzeppelin/upgrades-core/src/validate/query.ts:17:11)
      at Object.deployImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:31:3)
      at async Proxy.deployProxy (node_modules/@openzeppelin/hardhat-upgrades/src/deploy-proxy.ts:57:18)
      at async Context.<anonymous> (test/proxies/MyContract.proxy.spec.ts:33:21)

My contract is Initializable, OwnableUpgradeable, ERC20Upgradeable and uses SafeERC20 for IERC20.

Other than that, it does not use delegate call nor selfdestruct can somebody help me figure out why is my contract identified as unsafe?

4 Likes

I have also started experiencing this issue. Same as with @karl, there is no explicit delegate calls int the contract and it inherits from OwnableUpgradeable

1 Like

Same issue here, SafeERC20 is using address.sol which has some functions using delegatecall.

Ha, me too! You guys figure out any work around?

Hey @lou no mate; I couldn't find any workarounds.

I have raised an issue on GH about this topic. Apparently there is way to fix this. Please follow the instructions here https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/455

1 Like