Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: jscode017 on November 01, 2018, 04:44:41 AM



Title: How to ensure time in bitcoin or other blockchain tech?
Post by: jscode017 on November 01, 2018, 04:44:41 AM
How to know the miner didn't cheat with the time just send some time the miner wants to set when minning a block?


Title: Re: How to ensure time in bitcoin or other blockchain tech?
Post by: jscode017 on November 01, 2018, 04:53:02 AM
Thanks


Title: Re: How to ensure time in bitcoin or other blockchain tech?
Post by: bob123 on November 01, 2018, 08:53:45 AM
What do you exactly mean with 'time' ?

Are you talking about the timestamps included into blocks ? -> See ETFbitcoin's answer.


Or are you talking about a time interval (e.g. 10 minutes between each block) ?

In this case, it is the difficulty (better: hash target) which is being adjusted to get a 10 minutes average.
The target is being adjusted every 2016 blocks (~2 weeks with a 10 minute block time) using the time it took for the last 2016 blocks to be mined.
If it took less than 2 weeks, the target is being lowered (difficulty rises) and if it took more than 2 weeks, the target is being raised (difficulty decreases).


P.S. If you feel like your question already has been answered, make sure to lock the thread by clicking on 'lock topic' in the lower left of this page.


Title: Re: How to ensure time in bitcoin or other blockchain tech?
Post by: HeRetiK on November 01, 2018, 11:38:49 AM
By default, nodes/client will reject any blocks which timestamp difference is more than 2 hours.
[...]

Almost! For a block to be valid, the timestamp has to be less than 2 hours into the future and higher than the median timestamp of the last 11 blocks.

For reference: https://en.bitcoin.it/wiki/Block_timestamp


Title: Re: How to ensure time in bitcoin or other blockchain tech?
Post by: HeRetiK on November 01, 2018, 03:11:44 PM
Almost! For a block to be valid, the timestamp has to be less than 2 hours into the future and higher than the median timestamp of the last 11 blocks.

For reference: https://en.bitcoin.it/wiki/Block_timestamp

Thanks for the information. Assuming all last 11 blocks have exactly 10 minutes interval, does that mean block with timestamp about 1 hour in past still accepted?

Exactly. To my understanding using timestamps embedded in blocks for reference offers less attack surface than relying on a network time that is not protected by PoW (as is the case with the 2 hours into the future rule). However nodes obviously can't access future block timestamps so they have to fall back on their local time plus a network time offset.

Note however that this only means that the block is accepted, the timestamp has no influence on the ordering. If a node already has a valid block at the same height it will usually discard any competing block, regardless of the competing block having an earlier timestamp (as the timestamps can be easily faked). As far as I know that is implementation dependent however and not ruled by the protocol.