-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override transaction options (from, gas, gasPrice) in create and upgrade proxy #85
Comments
We potentially want these settings to be granular since each function can correspond to multiple transactions. |
@frangio Agree, but at least the |
Note that the plugin will use the signer that comes attached to the This means that you can customize |
I had a nightmare deploying to mainnet using |
Its totally a bad idea to not allow configuring the max base fee when deploying.... |
Here is a possible workaround for ethers.js: const FEE_DATA = {
maxFeePerGas: ethers.utils.parseUnits('100', 'gwei'),
maxPriorityFeePerGas: ethers.utils.parseUnits('5', 'gwei'),
};
// Wrap the provider so we can override fee data.
const provider = new ethers.providers.FallbackProvider([ethers.provider], 1);
provider.getFeeData = async () => FEE_DATA;
// Create the signer for the mnemonic, connected to the provider with hardcoded fee data
const signer = ethers.Wallet.fromMnemonic(/* mnemonic */).connect(provider);
// Get the contract factory connected to signer so it uses hardcoded fee data
const MyContract = await ethers.getContractFactory('MyContract', signer);
// Should now use hardcoded fee data for deployments
await upgrades.deployProxy(MyContract); |
I'm trying the above @frangio still the same result. everything works fine on the mainnet (even without the workaround above), but the same configuration fails on testnet (harmony) |
@gitbaq Please share more information about the error. |
When the gas price is set to >15 mins slow, it times out with : timed out waiting for transaction "txHash" error, any solution to that or should just revert to suggested ethers.js gas price? |
@noobshow Note that if it times out, you can just run the |
There are lots of deployments set up to go after each other. |
We don't do this because if the implementation deployment fails, then the proxy deployment will fail as well and it will cost a lot of gas for no reason. |
@frangio |
BTW, I didn't try on main net, yet. It fails on Ropsten, Mumbai and BSC Testnet. |
There is a workaround above: #85 (comment) |
Hello everyone, I am having problem with deployProxy function, the script worked as well for goerli and rinkeby (without using the workaround above) but on mumbai I am not able to deploy the contract. These are the library used:
This is the script:
Can someone please tell me was is wrong here? Thanks in advance. |
@SalvatoreCataniaVS Please post this question in the OpenZeppelin Forum and include the error message you are seeing. |
Is |
Maybe extending the Hardhat HRE following this example of the docs with the modifications indicated by @frangio :
extendEnvironment((hre) => { // hre.network.provider is an EIP1193-compatible provider. |
This is still an issue, no way to properly override gas values. |
The workaround doesn't appear to work if you use Any suggestions, or should I just do two transactions? Thanks |
@stevenkeith85 I was able to get the following example working (using a private key in this example instead of mnemonic): const FEE_DATA = {
maxFeePerGas: ethers.utils.parseUnits('100', 'gwei'),
maxPriorityFeePerGas: ethers.utils.parseUnits('5', 'gwei'),
};
// Wrap the provider so we can override fee data.
const provider = new ethers.providers.FallbackProvider([ethers.provider], 1);
provider.getFeeData = async () => FEE_DATA;
// Create the signer for the private key, connected to the provider with hardcoded fee data
const signer = (new ethers.Wallet('<MY PRIVATE KEY>')).connect(provider);
const MyContractV2Factory = await hre.ethers.getContractFactory("MyContractV2", signer);
await upgrades.upgradeProxy(proxyAddress, MyContractV2Factory, { call: {fn: 'myFunction'} } ); |
Thanks for helping out! I've got exactly the same code as you now, (except for the contract that I'm updating) and I'm still getting the same behaviour - UNPREDICTABLE_GAS_LIMIT if I have a Removing the I'm wondering if the contract size matters at all? I tried What's very strange is that the unit tests work. They deploy a proxy and then upgrade it to V2 so that I can run the new initializer function
which just updates the value of a new state variable in the V2 updates. What's also strange is that I've had the EDIT: If I remove the Now to figure out why I'm not the owner 😢 |
@stevenkeith85 To avoid UNPREDICTABLE_GAS_LIMIT, can you try setting your own estimate for the gas limit? e.g. signer.estimateGas = async(transaction) => {
return 200000;
} |
I just stumbled onto the issue. Seems I forgot to call one of the _ Pity the tests didn't complain about that, but at least I'm further along. No idea what the ownership weirdness is all about now, but I guess that's another issue. TLDR; If you get UNPREDICTABLE_GAS_LIMIT when you use |
@frangio @ericglau just checking in here before getting too deep into the rabbithole. Is the EDIT In Polygon given the code above I am getting an
const provider = new ethers.providers.FallbackProvider([ethers.provider], 1);
provider.getFeeData = async () => FEE_DATA;
provider.estimateGas = async() => BigNumber.from('<GAS_LIMIT>'); |
@0xmichalis Yes, it would be the same for |
This solution doesn't work to me. deployProxy or UpgradeProxy shows timeout error still
|
Reading this block: // Get the contract factory connected to signer so it uses hardcoded fee data
const MyContract = await ethers.getContractFactory('MyContract', signer);
// Should now use hardcoded fee data for deployments
await upgrades.deployProxy(MyContract); For some reason this worked for me instead of above: // Get the contract factory
let MyContract = await ethers.getContractFactory('MyContract');
// Connect to signer
MyContract = await MyContract.connect(signer);
// Should now use hardcoded fee data for deployments
await upgrades.deployProxy(MyContract); I was trying to deploy with GCP KMS key as signer (https://www.npmjs.com/package/ethers-gcp-kms-signer) |
Has there been any movement on this issue? It is really awkward for me to deploy to the production polygon chain. I've forked the upgrades repo and hacked gas into a couple of places just to be able to deploy and upgrade, but there really needs to be first class support for this in the library - it is essentially unusable for production polygon deploys at the moment. |
This is available in the latest releases of the Hardhat and Truffle Upgrades plugins by using the See documentation for the For example, to set
|
Add
from
,gas
, andgasPrice
as optional values to the options parameter ofcreateProxy
andupgradeProxy
, so the user can change the defaults for a specific transaction. For example:(found in truffle plugin, unsure if applies to builder as well)
The text was updated successfully, but these errors were encountered: