Skip to content

Consistent deployment gas price #87

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

Merged
merged 6 commits into from
Apr 8, 2020
Merged

Conversation

juniset
Copy link
Member

@juniset juniset commented Apr 3, 2020

Making gasPrice consistent across all deployment scripts. The gas price can be set in the .env file as DEPLOYER_GAS_PRICE. If not present the value of 20 Gwei will be used by default.

@juniset juniset force-pushed the maintenance/deployment_gasPrice branch from ee486f1 to be87cf3 Compare April 6, 2020 16:01
`Set ${deploymentWallet.address} as the manager of the TokenPriceProvider`);
}
const TokenPriceProviderSetKyberNetworkTx = await TokenPriceProviderWrapper.contract.setKyberNetwork("0x0000000000000000000000000000000000000000");
const TokenPriceProviderAddManagerTx = await TokenPriceProviderWrapper.contract.addManager(deploymentWallet.address, { gasPrice });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that you left out my if (!await TokenPriceProviderWrapper.contract.managers(deploymentWallet.address)) { but I think it's ok. Not really needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I dropped it by mistake when doing the rebase. I will add it again.

@@ -32,7 +33,7 @@ class MultisigExecutor {
signature = ethers.utils.joinSignature(split);

// Call "execute" on the Multisig wallet with data and signatures
const executeTransaction = await this._multisigWrapper.contract.execute(contractAddress, 0, data, signature, { gasLimit: 2000000 });
const executeTransaction = await this._multisigWrapper.contract.execute(contractAddress, 0, data, signature, this._overrides);
Copy link
Contributor

@olivdb olivdb Apr 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a multisig transaction that made the deployment script (silently) fail on CI: https://app.circleci.com/pipelines/github/argentlabs/argent-contracts/451/workflows/5f21b4a6-2bfe-491f-8113-527c50ddf6f0/jobs/485

I wonder if this could be because you have reduced the gasLimit from 2M to 300k here.

Copy link
Member Author

@juniset juniset Apr 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I did not see any fail transactions when running the deployment scripts. I guess we set it to 2M for a reason but it feels a bit too much. I've set it to 1M and confirmed that the deployment scripts work.

Copy link
Contributor

@elenadimitrova elenadimitrova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we should avoid using the .contract on etherlime contract wrappers as that points to the underlying ethers.js contract which for gasPrice handling differs in behaviour, in that it doesn't use the etherlime provider set default option. All .contract references in deployment scripts and otherwise can be replaced by direct calls on the wrapper, with the exception of encoding call data we use in some tests.

I am not in favour of passing gasPrice explicitly as it will be forgotten in some calls and we have no way of verifying it apart from trawling through the deployment test to watch for 2 GWei transactions.

This again raises the question of migrating to truffle which has a much clearer gasPrice handling than this.

const TokenPriceProviderSetKyberNetworkTx = await TokenPriceProviderWrapper.contract.setKyberNetwork("0x0000000000000000000000000000000000000000");

const TokenPriceProviderSetKyberNetworkTx = await TokenPriceProviderWrapper.contract.setKyberNetwork("0x0000000000000000000000000000000000000000",
{ gasPrice });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this script further up, there need to be updates to the MakerRegistryWrapper to use gasPrice explicitly as well, atm it uses 2 Gwei if you look in the deployment scripts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the TokenPriceProviderWrapper.contract.revokeManager below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I forgot those 2 when rebasing my PR. Done.


const defaultConfigs = {
gasPrice: 20000000000, // 20 Gwei
gasPrice: utils.bigNumberify(process.env.DEPLOYER_GAS_PRICE || 20000000000),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be in config rather than env vars? We have settings->deployer configuration in there already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because the value to use depends on the network status (typically the fast value on https://ethgasstation.info/) and we want to set it at the beginning of a deployment.

const KyberWrapper = await deployer.deploy(Kyber);
const ERC20Wrapper = await deployer.deploy(ERC20, {}, [KyberWrapper.contractAddress], TEST_ERC20_SUPPLY, TEST_ERC20_DECIMALS);

const addToken = await KyberWrapper.contract.addToken(ERC20Wrapper.contractAddress, TEST_ERC20_RATE, TEST_ERC20_DECIMALS);
const addToken = await KyberWrapper.contract.addToken(ERC20Wrapper.contractAddress, TEST_ERC20_RATE, TEST_ERC20_DECIMALS, { gasPrice });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initializing UniswapFactory step is also missing gasPrice here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@juniset
Copy link
Member Author

juniset commented Apr 7, 2020

In general we should avoid using the .contract on etherlime contract wrappers as that points to the underlying ethers.js contract which for gasPrice handling differs in behaviour, in that it doesn't use the etherlime provider set default option. All .contract references in deployment scripts and otherwise can be replaced by direct calls on the wrapper, with the exception of encoding call data we use in some tests.

I am not in favour of passing gasPrice explicitly as it will be forgotten in some calls and we have no way of verifying it apart from trawling through the deployment test to watch for 2 GWei transactions.

I considered both approaches and decided to use the contract object of ethers.js because it gives us more flexibility. In particular the wrapper object of etherlime doesn't give us any control on the gasLimit used for a transaction and we've had failing transactions in deployment because the gas was not correctly estimated. This is the reason we are already using the contract object everywhere in the scripts.

By the way I explained these 2 options on the call last week and thought we had agreed to use the contract object instead of the wrapper. I probably should have explained the tradeoff better.

This again raises the question of migrating to truffle which has a much clearer gasPrice handling than this.

If that's the case and we endup rewriting all the scripts for truffle anyway then maybe which option we choose (the contract or the wrapper) doesn't really matter as long as we are consistent.

Copy link
Contributor

@elenadimitrova elenadimitrova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I can't remember hearing about the etherlime wrapper object passing a bad gasLimit on transactions. Happy as I can be for now.

@elenadimitrova elenadimitrova changed the title Maintenance/deployment gas price Consistent deployment gas price Apr 7, 2020
@juniset juniset merged commit eb67742 into develop Apr 8, 2020
@elenadimitrova elenadimitrova deleted the maintenance/deployment_gasPrice branch April 8, 2020 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants