Can a miner set the EXACT timestamp of a block?

4

I know that miners can adjust the timestamp of a block, but can they control the exact timestamp datetime (within the +-2h rule)?

For example:
A miner mines a block at 2013-08-08 08:01:34.
Can the miner change the block timestamp to 2013-08-08 08:08:08?

user6266

Posted 2013-08-07T20:41:11.187

Reputation: 41

1In theory this is certainly possible - but they have the decide what timestamp they want before starting to mine. Is your question about theory or practice?Pieter Wuille 2013-08-07T21:13:39.970

1So the answer is yes --- For my question this is theory only. This doesn't really affect bitcoin but the coins that are using a moving average to calculate the difficulty. If the moving average is short enough and a miner have majority of hash power the miner could create a chain of blocks with 0s timestamp apart and mess up the difficulty. --- very unlikely though.user6266 2013-08-07T22:08:49.993

1And also this means that you can not use the block timestamp as a random time function. -- thank you Pieter for you answer.user6266 2013-08-07T22:17:05.123

Answers

6

Bitcoin miners can construct the block header, including the timestamp, however they want, as long as it adheres to the consensus rules. The shift you describe is well inside the 2 hour timerange, so it can be done when setting out to mine the block. It cannot however be done once the block is mined as the timestamp is part of the header, which is hashed into the PoW, hence changing the timestamp would invalidate the proof of work.

Most miners however prefer to increase/decrease the timestamp in order to have a simple way to alter the header, thus more hashes to compute. This is sometimes called time-rolling and is performed on top of the nonce-rolling.

cdecker

Posted 2013-08-07T20:41:11.187

Reputation: 7 878

1Your answer might be confusing, as the asker seems to propose to change the timestamp after a block is found. You might want to clarify that this is not possible (although, I think I have been clear on that in my answer).Murch 2015-06-25T08:31:03.300

1Thanks for the correction, I must have missed the fact that he is asking for a posteriori modifications of a block.cdecker 2015-06-25T08:53:30.750

1

The timestamp is part of the input for the mining process.

So, the miner can set an arbitrary timestamp, but must decide before hashing what timestamp he wants a potential block to have.

He cannot change the timestamp after finding a block, because the timestamp is part of the block, and a different one wouldn't be valid. To change the timestamp, he would have to start over mining.

Murch

Posted 2013-08-07T20:41:11.187

Reputation: 41 609