Closed bolpol closed 2 years ago
Hey @gfijrb, thanks for opening the issue.
I got this bug only on mumbai test network from polygon
Can i confirm my understanding:
Yes correct)
I had the same issue , only in mumbai network, I ran on rinkeby and that's ok
solidity: { version: "0.8.2", settings: { optimizer: { enabled: true, runs: 1000, }, }, },
"devDependencies": { "@nomiclabs/hardhat-ethers": "^2.0.2", "@nomiclabs/hardhat-etherscan": "^2.1.6", "@nomiclabs/hardhat-ganache": "^2.0.1", "@nomiclabs/hardhat-waffle": "^2.0.1", "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/test-helpers": "^0.5.15", "eslint": "^7.11.0", "eslint-config-prettier": "^6.12.0", "ethereum-waffle": "^3.4.0", "ethers": "^5.4.7", "hardhat": "^2.6.4", "prettier": "^2.1.2", "prettier-plugin-solidity": "^1.0.0-beta.1", "solc": "0.7.4", "solhint": "^3.2.1", "solhint-plugin-prettier": "^0.0.5", "web3": "^1.6.0" }, "dependencies": { "@openzeppelin/contracts": "^4.4.0", "chai": "^4.3.4", "dotenv": "^10.0.0" }
I see the same problem in Mumbai. Tested my code on other testnets and seems it is only Mumbai where the problem can be reproduced.
I also see the same problem on Mumbai. All other testnets work fine.
Speaking with the other hardhat team members we suspect this is an interaction between ethers
and mumbai
and will open an issue and dialog there to try and get to the bottom of it.
Failure to return the correct contract address is fatal to upgrading the contract
Getting same issue in Mumbai, this makes OpenZeppelin upgrades completely useless..
Speaking with the other hardhat team members we suspect this is an interaction between
ethers
andmumbai
and will open an issue and dialog there to try and get to the bottom of it.
Please also solve this problem as soon as possible
For all needing a quick solution, using the following plugin solved Mumbai issues: https://github.com/wighawag/hardhat-deploy
Can you try using the latest version of hardhat with polygon mumbai and see if that works?
I am having the same issue. The transaction hash is different than the one reported by the testnet explorer.
Confirmed same issue with latest hardhat (I only updated the package dependency to 2.8.0, not re-forked - I think it was forked when hardhat was 2.0.8, too big to recreate right now).
hardhat-deploy
works, but would be great to get this working if possible.
Had the same issue with version 2.8.0 of hardhat
I have same issue with Mumbai network on similar package.json configuration.
Also, I can't deploy contract to mainnet. Using same js code as here, I receive just 0xAddress where is nothing.
Code works fine 5 days ago.
I can confirm that this issue is present under some combination of ethers, hardhat-ethers, and maybe Mumbai. I'm working on finding the root of the problem.
In the meantime, if someone can help me reproduce it with a different network (e.g. ropsten, rinkeby, mainnet) that would be really helpful.
@alcuadrado I've had no issues with other networks, including rinkeby, arbitrum testnet, optimism testnet, only on mumbai
EIP1559 (London Fork) was activated on Mumbai last month. Does the block number have to be updated somewhere?
@alcuadrado I was able to find something that may be helpful. I had the issue when using this rpc endpoint: https://rpc-mumbai.maticvigil.com I just tried using an endpoint generated from alchemy (https://polygon-mumbai.g.alchemy.com/v2/.....) and it worked correctly.
I am unable to replicate this on the latest hardhat (v2.8.0) and hardhat-ethers (v2.0.3), it would be great if someone can attempt this again with the new versions and report back.
I have tested it with Infura on mumbai network - I still receive invalid token number. Still don't work on polygon mainnet. Maybe infura provider is problem?
My package dependencies with hardhat (v2.8.0) and hardhat-ethers (v2.0.3):
"@nomiclabs/hardhat-ethers": "2.0.3",
"@nomiclabs/hardhat-etherscan": "^2.1.3",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@nomiclabs/hardhat-web3": "^2.0.0",
"@openzeppelin/contracts": "^4.1.0",
"@openzeppelin/test-helpers": "^0.5.11",
"@pinata/sdk": "^1.1.23",
"chai": "^4.3.4",
"csvtojson": "^2.0.10",
"dotenv": "^10.0.0",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.3.1",
"hardhat": "2.8.0",
"inquirer": "^8.1.1",
"ipfs-core": "^0.8.0",
"prettier": "^2.3.1",
"prettier-plugin-solidity": "^1.0.0-beta.13",
"sinon": "^11.1.1",
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.0.5",
"web3": "^1.6.1"```
I have tested it with Infura on mumbai network - I still receive invalid token number. Still don't work on polygon mainnet. Maybe infura provider is problem?
My package dependencies with hardhat (v2.8.0) and hardhat-ethers (v2.0.3):
"@nomiclabs/hardhat-ethers": "2.0.3", "@nomiclabs/hardhat-etherscan": "^2.1.3", "@nomiclabs/hardhat-waffle": "^2.0.1", "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/contracts": "^4.1.0", "@openzeppelin/test-helpers": "^0.5.11", "@pinata/sdk": "^1.1.23", "chai": "^4.3.4", "csvtojson": "^2.0.10", "dotenv": "^10.0.0", "ethereum-waffle": "^3.3.0", "ethers": "^5.3.1", "hardhat": "2.8.0", "inquirer": "^8.1.1", "ipfs-core": "^0.8.0", "prettier": "^2.3.1", "prettier-plugin-solidity": "^1.0.0-beta.13", "sinon": "^11.1.1", "solhint": "^3.3.6", "solhint-plugin-prettier": "^0.0.5", "web3": "^1.6.1"```
We think it's unlikely, but still can you try another public RPC: https://rpc-mumbai.maticvigil.com
and see if the issue persists.
On RPC https://rpc-mumbai.maticvigil.com issue still exists :(
From our tests this issue happens only on Polygon-Mumbai testnet. We've managed to keep working by adding the hardhat-deploy plugin (really recommended and somehow not affected by this bug).
Alternatively if you don't want to add more dependencies, here's how we've managed to still get the proper deployed contract address:
const Contract = await ethers.getContractFactory("Contract");
const contract= await Contract .deploy();
await contract.deployed();
// This solves the bug in Mumbai network where the contract address is not the real one
const txHash = contract.deployTransaction.hash;
console.log(`Tx hash: ${txHash}\nWaiting for transaction to be mined...`);
const txReceipt = await ethers.provider.waitForTransaction(txHash);
console.log("Contract address:", txReceipt.contractAddress);
I can confirm that this is an issue with https://rpc-mumbai.maticvigil.com and I have already reported it. In the meantime, using alchemy is a valid workaround.
I also reproduced it using alchemy. It would be better to rewrite it using hardhat-deploy or the script above. @alcuadrado
@alcuadrado , is there some specific settings that could be causing this? Please give us more info so that we can also reproduce it in our rpc nodes and suggest a fix to the BlockVigil team.
I also reproduced it using alchemy. It would be better to rewrite it using hardhat-deploy or the script above. @alcuadrado
Can you provide steps to reproduce it using alchemy?
@alcuadrado , is there some specific settings that could be causing this? Please give us more info so that we can also reproduce it in our rpc nodes and suggest a fix to the BlockVigil team.
If you call eth_getTransactionByHash
to retrieve a pending transaction (something that ethers does under the hood), BlockVigil returns the 0 address as from
, and ethers uses that to compute the address of the contract being deployed.
Also getting this. except contract address is returning NULL after looking at the transaction details.
@alcuadrado , is there some specific settings that could be causing this? Please give us more info so that we can also reproduce it in our rpc nodes and suggest a fix to the BlockVigil team.
If you call
eth_getTransactionByHash
to retrieve a pending transaction (something that ethers does under the hood), BlockVigil returns the 0 address asfrom
, and ethers uses that to compute the address of the contract being deployed.
Even Alchemy returns the from
address as 0
on retrieving pending transactions using eth_getTransactionByHash
and it still gives the correct contract address
rachitsonthalia@Rachits-MacBook-Pro ~ % curl https://polygon-mumbai.g.alchemy.com/v2/ \
-X POST \
-H "Content-Type: application/json" \
-d'{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xb7d6352e5e5c7dbe87facbc375f38013ed4a4371900c985e0184e788bb945008"],"id":0}'
OUTPUT:
{"jsonrpc": "2.0", "id": 0, "result": {"blockHash": null, "blockNumber": null, "from": "0x0000000000000000000000000000000000000000", "gas": "0x1eaed",
I found same issue with your code, deployment script and same hardhat configuration. I tried with another deployment script with same hardhat configuration, same RPC it worked properly.
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
// deploy/1-deploy-ERC721Mock.ts
const deployERC721Mock: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {
deployments: { deploy },
getNamedAccounts,
} = hre;
const { deployer } = await getNamedAccounts();
if (process.env.WITH_PROXY) return;
const erc721Mock = await deploy("ERC721Mock", {
from: deployer,
args: [],
log: true,
});
console.log("Deployed Address: ", erc721Mock.address);
await new Promise((resolve) => setTimeout(resolve, 30000));
await hre.run('verify:verify', {
address: erc721Mock.address,
});
};
export default deployERC721Mock;
deployERC721Mock.tags = ["ERC721Mock"];
npx hardhat deploy --tags ERC721Mock --network mumbai
https://mumbai.polygonscan.com/tx/0xf1efd74d3b5d265208a76ffd649c7ba881fc41af65cb8be0ae23315a47fdd45f
Here's my hardhat.config.ts
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-waffle";
import "@nomiclabs/hardhat-etherscan";
import "hardhat-deploy";
import "solidity-coverage";
import "hardhat-contract-sizer";
import "hardhat-gas-reporter";
import { HardhatUserConfig } from "hardhat/types";
import { task } from "hardhat/config";
import * as dotenv from 'dotenv';
import { hardhatArguments } from "hardhat";
// import { accounts } from './test/shared/accounts';
dotenv.config();
const MNEMONIC = process.env.MNEMONIC
const secret: string = process.env.PRIVATE_KEY as string;
const infraKey = process.env.INFURA_API_KEY
const etherscanKey: string = process.env.ETHERSCAN_API_KEY as string;
// 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();
});
// 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
*/
export default {
defaultNetwork: "hardhat",
networks: {
hardhat: {
accounts: {mnemonic: MNEMONIC},
allowUnlimitedContractSize: true,
},
matic: {
url: 'https://rpc-mainnet.matic.network',
accounts: [secret],
},
mumbai: {
url: 'https://rpc-mumbai.maticvigil.com/',
accounts: {mnemonic: MNEMONIC}
},
},
solidity: {
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
typechain: {
outDir: "types/",
target: "ethers-v5",
},
contractSizer: {
alphaSort: true,
runOnCompile: true,
disambiguatePaths: false,
},
etherscan: {
// Your API key for Etherscan
// Obtain one at https://etherscan.io/
apiKey: etherscanKey,
},
gasReporter: {
currency: "USD",
gasPrice: 21,
},
namedAccounts: {
deployer: 0,
},
} as HardhatUserConfig;```
Can confirm, using hardhat, and deploying to mumbai, the contract address returned is always some invalid one that's already taken. Workaround is to get transaction from the hash and find the actual contract deployment address from that.
I spent forever trying to understand if there was a bug with how addresses are calculated using the sender address + nonce, and that lead no where. Glad I found this thread.
From our tests this issue happens only on Polygon-Mumbai testnet. We've managed to keep working by adding the hardhat-deploy plugin (really recommended and somehow not affected by this bug).
Alternatively if you don't want to add more dependencies, here's how we've managed to still get the proper deployed contract address:
const Contract = await ethers.getContractFactory("Contract"); const contract= await Contract .deploy(); await contract.deployed(); // This solves the bug in Mumbai network where the contract address is not the real one const txHash = contract.deployTransaction.hash; console.log(`Tx hash: ${txHash}\nWaiting for transaction to be mined...`); const txReceipt = await ethers.provider.waitForTransaction(txHash); console.log("Contract address:", txReceipt.contractAddress);
Thank you for the workaround.
I've also experienced this wrong address returned bug with other providers including Infura, Alchemy and Matic Vigil.
For example, when deploying an unrelated contract just today, I had this address returned for an existing contract on Mumbai: https://mumbai.polygonscan.com/address/0xc1eD83Ce887410D83F9181CB10CCB766f90204b4
We also had this issue on polygon mainnet with rpc: https://polygon-rpc.com or https://rpc-mainnet.matic.quiknode.pro. After diving into the code, we found out that the 'from' field of deployTransaction returned from rpc node is actually ZERO address which results in the wrong calculation of contract address. We strongly suspect this issue is related with EIP1559 upgrade. Can anyone from Polygon team help check on this?
Can confirm, using hardhat, and deploying to mumbai, the contract address returned is always some invalid one that's already taken. Workaround is to get transaction from the hash and find the actual contract deployment address from that.
I spent forever trying to understand if there was a bug with how addresses are calculated using the sender address + nonce, and that lead no where. Glad I found this thread.
Where do I find this (get transaction from the hash)? This is when deployed. Thanks
From our tests this issue happens only on Polygon-Mumbai testnet. We've managed to keep working by adding the hardhat-deploy plugin (really recommended and somehow not affected by this bug).
Alternatively if you don't want to add more dependencies, here's how we've managed to still get the proper deployed contract address:
const Contract = await ethers.getContractFactory("Contract"); const contract= await Contract .deploy(); await contract.deployed(); // This solves the bug in Mumbai network where the contract address is not the real one const txHash = contract.deployTransaction.hash; console.log(`Tx hash: ${txHash}\nWaiting for transaction to be mined...`); const txReceipt = await ethers.provider.waitForTransaction(txHash); console.log("Contract address:", txReceipt.contractAddress);
Thanks for the workaround @dmilla.
Hey, we have been working on a fix and currently testing it. We will be releasing a patch soon.
-Sandeep from Polygon team
Hi @ssandeep , I'm wondering if this issue occurs on polygon mainnet?
From our tests this issue happens only on Polygon-Mumbai testnet. We've managed to keep working by adding the hardhat-deploy plugin (really recommended and somehow not affected by this bug). Alternatively if you don't want to add more dependencies, here's how we've managed to still get the proper deployed contract address:
const Contract = await ethers.getContractFactory("Contract"); const contract= await Contract .deploy(); await contract.deployed(); // This solves the bug in Mumbai network where the contract address is not the real one const txHash = contract.deployTransaction.hash; console.log(`Tx hash: ${txHash}\nWaiting for transaction to be mined...`); const txReceipt = await ethers.provider.waitForTransaction(txHash); console.log("Contract address:", txReceipt.contractAddress);
Thanks for the workaround @dmilla.
I've tried this fix, still not able to Buy from the marketplace. I deleted the artifacts folder also then re compiled. Still same.
I'm pretty sure I'm getting this on Polygon mainnet with type2 transactions only.
We will be releasing a patch soon.
Can you link to the commit sha?
@ajb this is the PR: https://github.com/maticnetwork/bor/pull/305/files
From our tests this issue happens only on Polygon-Mumbai testnet. We've managed to keep working by adding the hardhat-deploy plugin (really recommended and somehow not affected by this bug). Alternatively if you don't want to add more dependencies, here's how we've managed to still get the proper deployed contract address:
const Contract = await ethers.getContractFactory("Contract"); const contract= await Contract .deploy(); await contract.deployed(); // This solves the bug in Mumbai network where the contract address is not the real one const txHash = contract.deployTransaction.hash; console.log(`Tx hash: ${txHash}\nWaiting for transaction to be mined...`); const txReceipt = await ethers.provider.waitForTransaction(txHash); console.log("Contract address:", txReceipt.contractAddress);
Thanks for the workaround @dmilla.
I've tried this fix, still not able to Buy from the marketplace. I deleted the artifacts folder also then re compiled. Still same.
Just noticed the transaction hash output for me is for the NFT contract not the Market contract ........ how can i check the transaction hash for the Market contract?
I updated deploy.js, reinstalled dependencies and deleted artifacts folder, recompiled. Still can't buy from marketplace, can create NFTs to show in it.
How do i redeploy to the same contract? When i run the script it creates a new contract with same problems.
Thanks
Hello @ssandeep, Is the patch deployed on Mumbai testnet?
I also want to report the same issue on the https://rpc-mumbai.maticvigil.com. I started a new project and deployed a contract to Mumbai but receive following token ID:
0xBd770416a3345F91E4B34576cb804a576fa48EB1
This is definitely an old contract
I use the newest version of Hardhat with Typescript.
For the moment I've deployed to an ethereum testnet to test the app, with no issues.
I'll deploy it to Mumbai then Mainnet when I'm able to.
Thanks
I'm pretty sure I'm getting this on Polygon mainnet with type2 transactions only.
We will be releasing a patch soon.
Can you link to the commit sha?
I too am currently experiencing this behavior on Polygon Mainnet for type 2 transactions on every RPC provider I can find.
All mumbai nodes behind MaticVigil RPC are on the new version. Can someone confirm by testing their mumbai endpoint?
If it works well, we'll deploy it to mainnet next week.
@SwaroopH yes I can confirm that with https://rpc-mumbai.maticvigil.com
the address is the same in the console and in the deployed contract
https://mumbai.polygonscan.com/tx/0x7c10cf52e6f95a47da7d0a99e16522b601397ab20003aa13994328a2a119a521
Edit by @alcuadrado: This is an issue with https://rpc-mumbai.maticvigil.com and I have already reported it. In the meantime, using alchemy is a valid workaround.
Incorrect address calculation or set in contract instance. I got this bug only on mumbai test network from polygon.
Expected result: token.address - the same deployed address on block explorer.
Result: token.address - not equal to real deployed contract address.
./scripts/Deploy.ts
./contracts/ERC721Mock.sol
package.json
hardhat.config.ts