where do the timestamps on blocks come from?

4

A stork brings them... or...

One of the basic principles on a dist. system is lack of a global clock.

So how are the timestamps assigned to blocks, by the machine that mines it? Couldn't it just insert a fake one?

On page 7 of the Ethereum whitepaper Vitalik says that the algorithm for checking that a block is valid contains the following check:

Check that the timestamp of the block is greater than that of the [median of the 11 previous blocks] and less than 2 hours into the future

So then this notion of time in BTC is quite fuzzy isn't it?

Is there anything I can read that will tell me the exact time bounds of the BTC system?

smatthewenglish

Posted 2016-09-22T10:55:11.603

Reputation: 1 063

3

See the accepted answer to the question here: https://bitcoin.stackexchange.com/questions/915/why-dont-the-timestamps-in-the-block-chain-always-increase

Bjarne 2016-09-22T11:33:26.877

1This information is from 2011, it still applies now in 2016?smatthewenglish 2016-09-22T16:44:11.893

2It still applies. It's part of consensus code: of one node across different blocks than another that's going to be messy. This makes it hard to change.Jannes 2016-09-23T10:22:28.857

1@Jannes thank you for the heads up. how about the timestamping on Ethereum, I guess it's somehow different- need to read the GHOST paper- do you know about litecoin?smatthewenglish 2016-09-23T12:45:53.003

2@s.matthew.english Don't know anything about Ethereum. In general there's no other way to do rough timestamps in a decentralized trustless way (we wouldn't need miners at all). Requiring higher precission timestamps would have been possible, but it makes miners more vulnerable to attack/human error by making them depend on properly configured and working (not DOSsed or manipulated) NTP. I'm not sure about Litecoin, but I doubt they changed anything other than going from 10 minutes to 2.5 minutes block time. Which by itself doesn't make their timestamps any more accurate or more trustworthy.Jannes 2016-09-27T13:23:34.457

Answers

5

A miner applies their own timestamp to a block.

Nodes add the first block they receive to the top their chain. They will not replace the current tip of their chain with a newly received block just because it has an earlier timestamp.

Therefore, you can think timestamp is a rough indicator of when the block was formed by the miner.


From bitcoin.it/wiki/Block_timestamp:

A timestamp is accepted as valid if it is greater than the median timestamp of previous 11 blocks, and less than the network-adjusted time + 2 hours.

So I suppose a miner can insert a "fake" timestamp, insomuch that it is between these two bounds. Nonetheless, a "fake" timestamp will not influence its position in the blockchain.

inersha

Posted 2016-09-22T10:55:11.603

Reputation: 2 236

1do you know where is the bitcoin code is the function that checks this?smatthewenglish 2016-09-22T13:04:34.413

1This information is from 2011, it still applies now in 2016?smatthewenglish 2016-09-22T16:44:00.627

2@s.matthew.english: Yes, this information is still accurate.Murch 2016-10-08T15:20:26.573

1@Murch Can fake time be used to drop the difficulty?Ilya Gazman 2018-01-14T21:25:11.250

@Ilya_Gazman: Yes, but only in limited fashion. See https://bitcoin.stackexchange.com/a/1588/5406, https://bitcoin.stackexchange.com/q/20479/5406

Murch 2018-01-15T05:11:31.580