Truffle: Option to default to block gas limit of connected network

Created on 16 Feb 2018  路  5Comments  路  Source: trufflesuite/truffle

Often users of Truffle have to trial and error the right gas value in truffle.js. But shouldn't there just be a default option to have gas be the current block gas limit of the network?

Fixed Next

All 5 comments

@JohnAllen Agree. We should be able to set this dynamically by querying the provider. On a related note, @gnidan has recently suggested re: truffle-contract 95 that we estimate gas for all transactions and supply that amount when no other preference is stated.

@JohnAllen note that you likely do not want to set your transaction gas limit to be the block gas limit: on mainnet, miners will have no way of knowing ahead of time that your transaction will use anything less than the full limit, and so it will take a long time for a miner to include the transaction (thinking that the transaction will be the only one in the block鈥攏o room for other, smaller transactions with potentially higher gas price)

@gnidan had the same thought.

The vast majority of deploys are not mainnet though, and many people determine the gas their contracts will cost during dev & testing and then hard code that gas number in truffle.js once they go to deploy to mainnet (to ensure they don't spend to much if something goes wrong). I think the vast majority know the costs involved when deploying to mainnet, as they've likely just purchased an ether or so to deploy

Also it's easy to check that the user is not deploying to mainnet.

Quite a few newcomers don't even know that the block gas limit has been raised twice, so their contracts won't deploy at 4.7m or 6.7m when they could have tried 8m in the first place.

@JohnAllen Small update: automated fueling of deployments and method calls have been added to truffle-contract 95. Believe this should accomplish what you're aiming for here. Unfortunately it won't be available until the release that upgrades to web3 1.0 comes out.

Thanks for pushing for this.

This has been released as part of v5. Thank you!

Was this page helpful?
0 / 5 - 0 ratings