Bitcoin introduces a timestamp server to ensure that there are no repeated payments. So, what is a timestamp and can a miner change it?
Under normal circumstances, the hash value obtained by hashing a group of data in a block and adding the timestamp generated by the transaction at that point in time, the block will broadcast the entire network to show everyone , And another new block is generated. The role of the time stamp here is to show everyone that at this point in time, this block and transaction are real. Only if the transaction exists at that point in time can the corresponding hash value be obtained. Each timestamp will incorporate the previous transaction timestamp into the hash algorithm, and each transaction will be linked to the previous transaction, forming a chain at the end.
However, when a Bitcoin block is generated, it basically involves two times: one is the time in the block header, which is placed by the miner, and the other is the actual time when the block was generated.
Although these two times are supposed to be almost the same, it does not preclude some miners from lying about time. To address or mitigate this phenomenon, Bitcoin has two mechanisms to prevent miners from tampering with timestamps.
- The median past time (MPT) rule, the timestamp must be higher than the median of the past 11 blocks. The median value of 11 blocks means that 6 blocks can be reorganized and the time will still not move backwards. Some people may think this is consistent with the example provided by Meni Rosenfeld's 2012 report, that is, for owning 10% An attacker with network computing power must perform six confirmations to reduce the success probability of the attack to less than 0.1%.
- The rule of future block time is based on the MAX_FUTURE_BLOCK_TIME constant. Compared with the median time from the equivalent node, the timestamp cannot appear in the next 2 hours or more. The maximum allowable difference between the time provided by the node and the local system clock is 90 minutes (another security measure). It is important to note that, unlike the MPT rules above, this is not a fully agreed upon rule. Blocks with timestamps at points too far in the future are invalid, but they may become valid as time moves forward.
Rule one ensures that the blockchain continues to move forward in time, while rule two ensures that the blockchain does not move too far forward. These rules have proven reasonable in preventing miners from tampering with Bitcoin's timestamps in a malicious manner.