2

As we know, time gets set on a block's header as the miner's current local time. Each node while accepting a block, checks if the new block's time is more than parent 's time and is not also in the future too far.

Question 1. Why doesn't geth just put the UTC time directly on the header ? why does the local time set on the computer matter ? I also don't understand how NTP matter in this case since all it does is check's some difference and logs the warning message and that's all

1
  • it does put time DIRECTLY in the header. thats the Time field
    – Nulik
    Feb 11 at 1:00
0
  1. I'm not sure if this answers your question, but: Geth uses Unix time which is universal (i.e. not dependant on timezone).
4
  • yes, that's why I am curious why need for NTP protocol at all Feb 10 at 22:00
  • Oh, node operator local clocks might not be synced which means your peers might drop your blocks: github.com/ethereum/go-ethereum/blob/… > "I also don't understand how NTP matter in this case since all it does is check's some difference and logs the warning message and that's all." You need to sync your clock yourself, since it's a privileged call.
    – Sasa Milic
    Feb 10 at 22:18
  • so we can't get correct UTC value if the local time is wrong, correct ? Feb 10 at 22:21
  • Yea, I think that's the case.
    – Sasa Milic
    Feb 10 at 23:26
0

The problem are block with a timestamp in the future. Should a client accept them? If the timestamp is within certain range seems reasonable to accept them.

If it is too far into the future perhaps it is some kind of selfish mining attack.

6
  • Yes, but I think my question was a little bit different. I understand consensus, but I am asking how a good miner puts a timestamp on a block when it creates that. I am not sure why NTP is necessary. when the miner has to put a timestamp, it can pull the NTP server and whatever it returns, put on a block. But it doesn't work like that. When you join network as a miner, it makes you sync with NTP first so that your local time is correct. I guess, this is because it doesn't do NTP request every time a block starts to get mined. I don't know . :( Feb 13 at 22:46
  • @NikaKurashvili I don't know why NTP is required. I'd guess that someone had lost a lot because the time was wrong and they complained enough for the developers to require it.
    – Ismael
    Feb 13 at 23:43
  • If the local time is wrong in terms of the returned value from NTP, the geth does the log.warn. Do you think this prevents connecting to the network or still allows it ? I don't know how powerful is log.warn and if it halts the program. Feb 13 at 23:45
  • Because I know that if local time is wrong, it somehow makes sure you get disconnected from more and more peers, resulting in you are kicked out of the network Feb 13 at 23:47
  • 1
    I'd guess that over time clients will have different views of the latest blocks and they will disconnect other nodes that do not match the queries thay are expecting.
    – Ismael
    Feb 14 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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