Hey, I'm continuing development on an upgradeable smart contract that I started work on a month or two ago. I'm attempting to redeploy the contract on the Polygon Matic Mumbai testnet and I'm encountering the following error:
(node:98215) UnhandledPromiseRejectionWarning: Error: Timed out waiting for transaction 0x0d619d026c0ace55b8bc64f54dc83017240b87fe34fd32243bbc27bf107e4126
at waitAndValidateDeployment (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/@openzeppelin/upgrades-core/src/deployment.ts:70:15)
at fetchOrDeployGeneric (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/@openzeppelin/upgrades-core/src/impl-store.ts:43:5)
at Object.deployImpl (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:40:10)
at Proxy.deployProxy (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/@openzeppelin/hardhat-upgrades/src/deploy-proxy.ts:57:18)
at main (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/scripts/deploy-script.js:7:15)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:98215) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:98215) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I was able to deploy and upgrade this contract just fine a while ago, but now that I've come back to the project I can't seem to get it to redeploy. I've made substantial changes to the contract so right now I'm just trying to deploy a fresh copy of the contract, not upgrade it.
Code to reproduce
My actual contract is pretty complex so I don't think it's useful to post it all here. I was able to reproduce the exact error by following this tutorial: https://docs.openzeppelin.com/learn/upgrading-smart-contracts
Box.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Box {
uint256 private _value;
// Emitted when the stored value changes
event ValueChanged(uint256 value);
// Stores a new value in the contract
function store(uint256 value) public {
_value = value;
emit ValueChanged(value);
}
// Reads the last stored value
function retrieve() public view returns (uint256) {
return _value;
}
}
deploy-script.js
// scripts/deploy_upgradeable_box.js
const { ethers, upgrades } = require('hardhat');
async function main () {
const Box = await ethers.getContractFactory('Box');
console.log('Deploying Box...');
const box = await upgrades.deployProxy(Box, [42], { initializer: 'store' });
await box.deployed();
console.log('Box deployed to:', box.address);
}
main();
hardhat.config.js
require("@nomiclabs/hardhat-waffle");
require('@nomiclabs/hardhat-ethers');
require('@openzeppelin/hardhat-upgrades');
require('dotenv').config();
const PRIVATE_KEY = process.env.PRIVATE_KEY;
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.4",
networks: {
matic: {
url: "https://matic-mumbai.chainstacklabs.com",
accounts: [PRIVATE_KEY],
}
},
};
Environment
MacOS Big Sur with Hardhat 2.6.5
What I've tried
There appear to be several issues describing this type of problem on this forum, so I made sure to go through those threads and try what was suggested there before posting. Here's what I've tried so far and the results.
-
Tried switching RPCs. I tried all the public testnet RPCs listed here: https://docs.polygon.technology/docs/develop/network-details/network
-
Also tried setting up a private maticvigil node and got the same error as the public RPC.
All of these RPCs produced errors, but not the same error each time. Some of the RPCs produced this error:
(node:98373) UnhandledPromiseRejectionWarning: HardhatError: HH110: Invalid JSON-RPC response received: {"text":"The requested URL was not found on this server.","code":404}
at Object.parseJsonResponse (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/hardhat/src/internal/util/jsonrpc.ts:47:11)
at HttpProvider._fetchJsonRpcResponse (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/hardhat/src/internal/core/providers/http.ts:173:14)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at HttpProvider.request (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/hardhat/src/internal/core/providers/http.ts:55:29)
at GanacheGasMultiplierProvider._isGanache (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/hardhat/src/internal/core/providers/gas-providers.ts:315:30)
at GanacheGasMultiplierProvider.request (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/hardhat/src/internal/core/providers/gas-providers.ts:304:23)
at EthersProviderWrapper.send (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
at Object.getSigners (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:23:20)
at getContractFactoryByAbiAndBytecode (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:250:21)
at main (/Users/ryan/Desktop/programming/NFTMemeMachine/hardhat-test/scripts/deploy-script.js:5:15)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:98373) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:98373) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
-
Even though I don't want to upgrade the contract I deployed a month ago, I tried to upgrade that contract just to see what would happen and I got the same error listed at the top of this thread.
-
Tried setting the gas and gasPrice in hardhat.config.js to 8000000, then tried setting them to "auto" and got similar errors.
-
Tried setting hardhat.config.js timeout to 20000 and got similar errors.
-
Tried setting hardhat.config.js chainId to 80001 and got similar errors
It's also probably worth noting that I set up automated tests for my original contract. One of those tests includes testing the deployProxy upgrade functionality and that test passes. At this point, I'm guessing there may be some issue with my environment or possibly the upgrades npm plugin which is why I'm posting this here, but I'm not sure what that issue could be. I suppose that there could also be an issue with the RPCs or the testnet, but that seems very unlikely to me.
I'd really appreciate any help. Please let me know if there's any other information I can provide or if there's another forum where I should post this issue.