Because in theory the block gas limit can be reached any time, how would a fully automated contract need to react?

  1. How to recognize reliable that it's the block gas limit that rolls back the state change?
  2. How to retry the transaction in a secure way? Idempotentcy is not always possible.

The block gas limit works in a different way than the transaction gas limit.

The rule is that a block may not have more gas used than the limit. If a transaction would go over that limit, it just can't be included in the first place. For this reason, the default mining algorithm basically runs transactions in order of gas price, and reverts any that over the limit.

For the developer, a low gas block limit just means large transactions don't happen. Nothing is lost if a transaction doesn't fit, and it may very well be in a near-future block (short spam attacks). The concern should be if a transaction is time-sensitive (such as a publication of a state channel's state), at which the simplest response is simply to wait longer.

  • Does that mean I can DoS miners by sending them lots of transactions high-priced that ultimately go over the block gas limit? The miner would have to run them to discover that they used more gas than the limit, and it wouldn't cost me anything since they would never get mined. Or does the miner consider something else when deciding whether a transaction may hit the block gas limit, like the transaction gas limit? – Edmund Edgar Oct 28 '16 at 0:29
  • The transactions would remain valid even if they are not included, so the miners could (and by default would) simply hold onto those transactions and execute them later (for profit!). If the transactions are so large that they would not fit inside a standard block, the miners can also just raise the limit until they can fit the large transactions. – Matthew Schmidt Oct 28 '16 at 14:02
  • Executing a transaction in one block doesn't tell you how much the gas will cost when you execute it in another block, because the transaction execution flow may depend on state that has changed in between. – Edmund Edgar Oct 28 '16 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.