I am aware that smart contracts running on top of EVM can access certain system properties such as timestamp, block number, and gas limit.

I am also aware that such properties can be controlled by the miner, and one best practice is that we should be very cautious in case using such system properties.

However, my question is that, what could go wrong, if a malicious miner intentionally control the "block.gaslimit" property used by Solidity code? Is there any "real-world" attacks or threats based on that? Just want to understand more here. Thanks a lot.

  • Also, what about the block.number property, any real world attack towards smart contract by exploiting the usage of block.number? Apr 2, 2019 at 19:31

1 Answer 1


Note that the miner can only slight change the gas limit. A block header is invalid if the gas limit is more than 1/1024 plus or minus the parents gas limit, meaning if block 10 has a gas limit of 1,000,000, block 11's gas limit must be between 1000000-floor(1000000/1024) and 1000000+floor(1000000/1024).

So contract writers should of course should just be aware of this when writing contracts, so they shouldn't make assumptions like "the gas limit will always be x"

As for your comment about block.number, it's the same really. A block is only valid if its block number is the parents block + 1. So a contract can't make assertions that transactions will be mined at a certain time, but they can be assured that block.number will be the block that it was actually mined in.

  • We are evaluating some smart contract security analyzer's capability. In that sense, do you think which is more reasonable, let them find a block.number dependent random number generation or a gaslimit dependent random number generation? Strictly speaking, both are not desired. Apr 3, 2019 at 7:42
  • I think they're both equally nonsensical, but gaslimit is more manipulable. A miner can choose a much wider variety of gas limit if they know a certain one will get them a better outcome, but a miner can only choose whether or not to include the transaction in a certain block height they're trying to mine.
    – natewelch_
    Apr 3, 2019 at 17:49
  • To phrase that another way, if a miner knows a certain gas limit within the allowed bounds will make them win a game, they can try to mine every block with that gas limit. But if they know a certain block will make them win the game, well, they only have the 1 chance to mine that block.
    – natewelch_
    Apr 3, 2019 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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