Transaction Gas Settings Need Improvement


#1

When making a transaction on the DApp, the gas limit and gas price are not set to good values. For example, the updateStatus function only needs a maximum of ~170,000 gas, I believe, and yet 500,000 is used. The gas price also does not seem set to a good value (default was 1 Gwei even when gas station showed ~7 Gwei should be used).

Using a higher than necessary gas limit is bad for both the transaction and the network as a whole, as the gas limit contributes to the block gas limit, but miners only receive ETH based on actual gas used. This means that transactions with higher than necessary gas limits either go un-mined, or unnecessarily fill up blocks preventing other transactions from being included in the block. The estimateGas function can be used to find a good value to include when making the transaction (can reach out to me directly if necessary for examples).

The gas price should also be improved, perhaps by making a call to the gas station and setting it when making the transaction, rather than relying on metamask to get a good value.

These gas issues can lead to a state where metamask is essentially unusable. When submitted with bad settings, they often do not even get picked up by etherscan and metamask does not prompt the user to increase the gas price because the transaction is taking too long. Transactions outside the FOAM DApp, whether simple transfers or interacting with another DApp, will fail because the account nonce has increased locally so the new transactions are waiting on previous transaction to confirm (which it never will, seemingly). The only way to fix this issue is to go through the “reset account” flow on metamask which deletes account history (and fixes the nonce issue). The “reset account” flow can be intimidating, and it should not be expected that a user has to modify the gas settings that are populated when the metamask dialog appears.

(the above is a bit of speculation, metamask does get into a bad state and this is my theory of what’s happening, but I haven’t investigated it closely)


#2

Hey Nick thanks for the detailed feedback, the 1 Gwei default value is set by Metamask, we don’t set a gas price explicitly anywhere, as for the 500,000 Gas Limit that is a good point, we’re working on better scripting to address these issues and hopefully will have it fixed soon.


#3

I know that you’re letting metamask handle it, but you could pass in a better gas price to the transaction if metamask’s default is bad (which it seems to be)


#4

Noted! Have forwarded this to the Devs, we’re working on better scripting to have better gas price estimations, your suggestion will be taken into consideration for implementation as well. Thanks Nick!


#5