2
So I understand that difficulty increases by some algorithm calculated every 2016 blocks. But my understanding is that this algorithm attempts to set a difficulty such that the average time it takes to mine a block is about 10 minutes. My understanding of verifiable time is that the only way to measure a time in minutes is by using trusted timestamping, which I assume bitcoin doesn't do (since it's not supposed to trust anyone).
So my question is, how does the bitcoin protocol measure time in seconds or minutes in order to determine what the difficulty should be?
I'm reading here that "every Bitcoin client compares the actual time it took to generate these blocks with the two week goal and modifies the target by the percentage difference". How does every bitcoin client affect the difficulty set by the network? Is this a scenario where there's minimum and maximum bounds on difficulty and any difficulty within those bounds is accepted by nodes in the network? Or is the calculation of difficulty something discrete and precise?
Ah so it's trusting that the miners of the first and last block in the set of 2016 wrote a correct timestamp. Couldn't malicious miners that want the difficulty to be lower or higher spoof different timestamps if they end up mining one of those critical blocks? – B T – 2017-05-25T21:25:50.110
Is there something in the protocol that puts verifiable or statistical bounds on the correctness of the block timestamps? – B T – 2017-05-25T21:29:31.057
@BT I'd have to look through the code for any possible checks on the timestamp, but there should not be any. Miners can put whatever timestamp they want, and if they have more than 50% hash power, they can force blockchain to act however they want to, since most of the blocks are theirs, and they control it. But with less hashing power, this is not possible because other people mine and find blocks, and see there is something fishy going on - same for the timestamp spoofing. – epson121 – 2017-05-27T16:12:10.337
1
edit: looks like I was way off on this last comment. See this for more info https://en.bitcoin.it/wiki/Block_timestamp
– epson121 – 2017-05-27T17:11:41.120Ah very interesting. Add this to your answer and I'll accept it! It would seem to me that this would allow time as measured by the bitcoin network to drift with respect to real time if there is some pressure to manipulate timestamps, but places some statistical constraints on how fast it can drift according to what percentage of the network has incentives to manipulate those timestamps. This could be pretty interesting as a way to validate timestamps in the future! – B T – 2017-05-28T22:34:17.803