Bitcoin: "Difficulty Adjustment"
To me it is fascinating how Satoshi, back in November 2008 said the time between blocks is roughly 10 minutes. Before Bitcoin was released. Not knowing how many computers were out there solving the block for the Bitcoin timechain.
I know it has to do with the Difficulty Adjustment but I have been looking for a really good explanation. This Comment was posted on Reddit /bitcoin subreddit a few hours ago. If it isn't any good, please comment and I will compile a better post with your responses.
Thank you.
https://www.reddit.com/r/BitcoinBeginners/comments/18eyf3d/bitcoin_difficulty_level/
igadjeed
ยท
2 hr. ago
TL;DR
Difficulty is defined as 1 for Satoshi's original mining target 0x1d00ffff which equates to 4,295,032,833 hashes per block (average)
hashes per block = 4295032833 * difficulty
Difficulty is a made up number. The winning condition for mining is a block with a header which has a hash less than target. The target is adjusted every 2016 blocks using a simple time ratio formula
New Target = Old Target * (Actual Time of Last 2016 Blocks / 20160 minutes)
It's easy to see how that formula calibrates target for 10-minute average block intervals
A bigger target is easier and vice versa
More about target in Antonopoulos, chapter 10
https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch10.asciidoc
How many hashes per block, average? This is another simple formula, because hashing is simple random probability guessing
average hashes per block = 2^256 / target
Historical quirk ...
When the first target was hard-coded into the genesis block, the adjustment code was written so that the target can never be larger than this initial value, never easier. The effect was that the first 32256 blocks all have this initial value and those blocks took about 15 minutes each. The first adjustment (harder, smaller target) was in block #32256
When difficulty was defined, it was defined that difficulty 1 equals the first target. The target can never be bigger (easier) than 0x1d00ffff, and this equates to difficulty 1
https://en.bitcoin.it/wiki/Difficulty
Using the second formula above, the average number of hashes for the initial target 0x1d00ffff is
2^256 / 0x00FFFF0000000000000000000000000000000000000000000000000000
= 0x100010001
= 4,295,032,833
which is slightly bigger than 232
Thus, the ratio of hashes per block to difficulty is 4,295,032,833
That's how it lines up
Target adjustment happened a few blocks ago. Current target is 0x17042e95
Hashes per block
2^256 / 0x042E950000000000000000000000000000000000000000
= 289081079999067160436035
Divide by 4,295,032,833 to calculate difficulty
289081079999067160436035 / 4295032833 = 67305906902031
Alternatively, as per the Wiki page
difficulty = difficulty_1_target / current_target
0x00FFFF0000000000000000000000000000000000000000000000000000
/ 0x042E950000000000000000000000000000000000000000
= 67305906902031