Open antazoey opened 2 years ago
Yeah, I think this is a good feature to add.
To clarify, this warns if the gas used by a transaction is getting close or exceeds a limit imposed by that particular network.
For EIP1559 chains, there are actually two limits: a target block limit (15m for Ethereum, can exceed this but probably not very easy in practice) and a max block limit (30m for Ethereum, cannot exceed this as it is a hard limit)
For non-EIP1559 chains, there is usually just one limit (and it depends on chain, I think BSC is something crazy like 120m)
As an aside, at first I thought this meant to warn of congested network conditions, such as a spike in gas price, or for EIP1559 chains, seeing when the average block gas limit is above the target by a certain amount for the past X blocks. That might also be handy too, as a warning that things will be expensive. I've seen dapps warn about this in their UI
So, to warn for congested networks, we need to track the block base gas fees ourselves? Will this require a little sqlite database?
Well, actually EIP1559 has a "natural" definition for when congestion is happening: when more than 50% of the block gas limit is being used. So, we can just query a couple of blocks in the past and see if there's consistently like 70%+ being used or something.
Overview
If the gas on a transaction is really high, warn the user.
Specification
Metamask uses >= 90% of
blockGasLimit
. https://github.com/MetaMask/metamask-extension/blob/develop/CHANGELOG.md?plain=1#L1893Would that make sense for us too?