Open theo-zil opened 1 week ago
I was submitting a transaction with a manually set gas limit. If I set the gas limit to 10_000_000, the transaction fails. If I set it to 12_000_000, it succeeds, but only consumes only 2_767_052 gas. Just as an example of why we can't rely on the transaction gas limit to judge whether a transaction would fit into the block or not.
Currently, block building happens in two steps:
This causes blocks to be under-filled, assuming the transaction gas limit is overestimated as a rule.
Here's what should happen instead:
For the last transaction, a potentially easy way to detect it would be to always pass
min(transaction.gas_limit, block_gas_remaining)
as the actual gas limit to the EVM for execution; then on out-of-gas errors, iffblock_gas_remaining < transaction.gas_limit
then re-insert that last transaction into the mempool (instead of discarding it as failed) and cease iteration.