OpenZeppelin / openzeppelin-upgrades

Plugins for Hardhat and Foundry to deploy and manage upgradeable contracts on Ethereum.
MIT License
618 stars 262 forks source link

Deployment to Polygon times out #525

Closed romansemko closed 2 years ago

romansemko commented 2 years ago

Since some time we are having issues to deploy even basic ERC20 type of upgradeable contracts to Polygon. The transaction simply times out after a while with.

Error: Timed out waiting for implementation contract deployment to address XXXXXXX with transaction YYYYYYY

Re-starting the transaction (by running the same script again) or increasing the timeout does not help. Same error.

Connecting to the node and asking for the timed-out TX with hash YYYYYYY returns the TX without block number. It is simply never picked. After a while the node returns null for the transaction. I guess, it is being discarded.

Tried public and dedicated nodes. Ankr, Infura, Quiknode - you name it. Nothing works. Same behaviour.

Polygon said that we should use type 2 TXs with EIP1559, but, as far as I can see, there is no way to tell OZ to use it.

Other networks like BSC, Ethereum work fine.

Has anyone else encountered this issue? Any idea how to make it work?

Thanks!

romansemko commented 2 years ago

According to Polygon, legacy TXs (not type 2) should still be supported. So I am not sure that EIP1559 is really the issue here.

Using the latest 1.12.0 version of the plugin. How to reproduce:

Testcoin.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";

contract TestCoin is ERC20Upgradeable {
    mapping(uint256 => bytes) public data;

    function initialize() public initializer {
        __ERC20_init("TC", "TC");
    }
}

Deployment with hardhat:

  const Contract = await ethers.getContractFactory("TestCoin");
  const contract = await upgrades.deployProxy(Contract, []);
romansemko commented 2 years ago

Added a repo with basic example that fails to deploy on Polygon:

https://github.com/romansemko/test-deploy-upgradeable-polygon

ericglau commented 2 years ago

Hi @romansemko, there was an issue related to Polygon that was fixed (https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/487) in version 1.12.1 of the Hardhat Upgrades plugin. Could you try updating the @openzeppelin/hardhat-upgrades package (the latest version is 1.15.0) and see if it helps?

romansemko commented 2 years ago

Hi, unfortunately no. I think it has something to do with gasPrice, since we also had same issues yesterday with usual transactions being timed out. The only thing that helped was increasing the gasPrice 10% above the value returned by provider.getGasPrice().

Is there a way to manually set gasPrice in deployProxy call I have tried this, bout it did not work (same timeout issue):

  const contract = await upgrades.deployProxy(Contract, [], {
    gasPrice: (await ethers.provider.getGasPrice()).mul(120).div(100),
  });
frangio commented 2 years ago

There is no out of the box way to customize gas but you can try this workaround: https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/85#issuecomment-1028435049

romansemko commented 2 years ago

Hi @frangio the workaround worked. We can work with that for the time being.

nbarraille commented 1 year ago

Any news on this? I am having a similar error, both with a local ganache chain and on Polygon Mumbai:

Error: Timed out waiting for implementation contract deployment to address 0x774486e1015c465e8CB709EC6612C19B01090CfE with transaction 0x1d90399f114553de70f8fc76c5a03a2b1f47a0e91c99d009387c149718ded502

Even though the transaction was mined in a few seconds way before the timeout expired: https://mumbai.polygonscan.com/tx/0x1d90399f114553de70f8fc76c5a03a2b1f47a0e91c99d009387c149718ded502

I am using version 1.22.1

robertxd30 commented 1 year ago

i faced same issue how can i fix this? image

apolishch commented 1 year ago

I'm also experiencing this on Sepolia