Openzeppelin-contracts: Change crowdsales to use timestamps instead of block numbers

Created on 4 Aug 2017  路  3Comments  路  Source: OpenZeppelin/openzeppelin-contracts

Due to the difficulty bomb it is very hard to estimate block numbers.

Most helpful comment

Some thoughts from my end (cross post from Slack)
For now you are generally using block.number instead of block.timestamp.
Advantages of what you do:

  • block.number will always increase by one compared to previous block, this is guaranteed by the protocol.
  • block.timestamp can be minimally gamed by a miner, see here and here
    Disadvantages:
  • the future block time is unknown and leads to surprises, especially with the latest difficulty bomb and ice age forks.
    Given that ICOs usually run over several days, the in-accuracy due to unknown block times is actually higher than the max 15 minutes practical gamable of the block.timestamp. Hence I鈥檇 suggest to use block.timestamp (or now) instead of block.number for your crowdsale contract.

All 3 comments

Some thoughts from my end (cross post from Slack)
For now you are generally using block.number instead of block.timestamp.
Advantages of what you do:

  • block.number will always increase by one compared to previous block, this is guaranteed by the protocol.
  • block.timestamp can be minimally gamed by a miner, see here and here
    Disadvantages:
  • the future block time is unknown and leads to surprises, especially with the latest difficulty bomb and ice age forks.
    Given that ICOs usually run over several days, the in-accuracy due to unknown block times is actually higher than the max 15 minutes practical gamable of the block.timestamp. Hence I鈥檇 suggest to use block.timestamp (or now) instead of block.number for your crowdsale contract.

Thank you for your thoughts @SCBuergel. I agree with all of them. We have done the change (#353) because of the disdvantage you stated, and the reasoning that it's a good trade-off for crowdsales. I'll recap this in the release notes.

Finally.

Months ago I reported that the ethereum team members had agreed that a block time could not be gamed by more than a few seconds. Certainly not the 15 minutes mentioned above.

The original comment was to prevent it being used for things like rand seeds.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xiaoyao1991 picture xiaoyao1991  路  3Comments

rstormsf picture rstormsf  路  4Comments

shyheim103 picture shyheim103  路  4Comments

valmack picture valmack  路  3Comments

nventuro picture nventuro  路  4Comments