I've seen how nodes gather network time data, but how is it enforced in the blockchain?

Are all of the timestamps digitally signed and included in the block as proof?

up vote 4 down vote accepted

First, where do these time samples come from: when your client connects to peers in the network it exchanges a version message with them. Among other things this message contains the current UTC timestamp at the peer. Your client then calculates an offset between the time at its peer and its own clock. The network time is simply the local timestamp + the median of all offsets of its peers. So you can see that we have a relatively simple attempt at synchronizing the clocks in the network, but depending on the sample of peers you connect to they can still vary wildly.

About enforcing the timestamps: there are very few places the timestamp appears in the communication between peers, likely the only place where it is actually enforced is in the block header. Should a peer receive a new block while being synched with the network, and the timestamp differs more than 2 hours from its local timestamp, it'll discard the block as invalid (source). The idea behind this check is that a client could attempt to skew the perceived difficulty seen by a node that is synchronizing with the rest of the network.

  • Thank you cdecker! So it's only future blocks that are rejected for being too young not past blocks for being too old, the 2 hour failure? Thank you so much in advance! – user5107 Jan 5 '14 at 2:23
  • That seems to be correct, although I seem to remember that it was checked both ways, but I can't find proof of that :-) – cdecker Jan 5 '14 at 13:40
  • Yes, you're right. I found it but lost the link, lol. Past blocks are governed in sequence while future blocks are governed in real time. Thank you so much for your help! – user5107 Jan 5 '14 at 18:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.