First of all a good way to look up any Bitcoin related topics search these sites: Bitcoin.org or Bitcoin Wiki.
Let´s dig deeper into the questions of mining.
This post will be simplistic and if you want, you can look deeper into Bitcoin wiki or search the web.
Difficulty
The difficulty is changed every 2016 blocks, like many already have heard.
Let´s talk more about this change later, first what is Bitcoin’s difficulty and why is it important?
Difficulty is a measure of how difficult it is to find a hash below a given target. The Bitcoin network has a global block difficulty. All Bitcoin miners can find the difficulty of a block since it´s a deterministic calculation based on the data of the previous blocks (one knows exactly the parameters used in the calculation). So independent miners in the decentralized BTC network can do the calculation and come to the same result.
The idea of difficulty is to keep the coin inflation/issuance and block confirmation steady within a 600 seconds interval. Miners are trying to find the correct nonce (golden nonce/ticket), this nonce results in a hash value lower than the target difficulty. Full nodes will check if the nonce/block have a double SHA-256 hash value lower than the difficulty target, if so they will accept the block.
So, what is the formula for difficulty?
Difficulty level = Difficulty target / Current target
The target is a 256-bit number (extremely large) that all Bitcoin clients share.
Each block stores a packed representation (called “Bits”) for it´s actual hexadecimal target.
Note that the Difficulty Target is a hexadecimal notation of the target hash whose mining difficulty is 1.
Still don´t get it? When the 2 hexadecimal numbers are divided, it results in difficulty or some call it difficulty level a whole number. At block height 786240 the difficulty was 4.871241e+13 or 48.71 Trillion.
Sometimes miners can get lucky and find it with significantly fewer guesses.
Just to specify Bitcoin has it´s own time protocol, so instead of using normal time like UTC I will use the block height in the following graphs. A friend has actually written a great article about living on Satoshi time.
The difficulty is the approximate numbers of hashes that miners need to perform to find a block.
Difficulty adjustment
Like stated in the start of the article difficulty is adjusted every 2016 block (approximately every = 2016 blocks * 10 min = 20160 min/60/24 = 14 days ). This is also called difficulty epoch adjustment. ‘
So, the Bitcoin network recalculate the current target, by taking the last 2016 blocks and how long it took to mine them.
So, if it took 20000 min for the last 2016 blocks the difficulty will increase, and if the difficulty is 20300 the difficulty will go lower.
The ratio is measured in percent.
If the correction factor is greater than 4 (or less than 1/4), then 4 or 1/4 are used instead, to prevent the change to be too abrupt.
The difficulty adjustment algorithm has an off-by-one bug that leads to the calculation based off of the previous 2015 blocks, rather than precisely 2016.
It´s interesting that the difficulty adjustment happens every 2016 blocks. It might be a coincidence but in 1933 there was an executive order called 6102.
I have graphed the average block time here, when difficulty adjustments happened.
As you see the start of the BTC network was a bit shaky, but it´s pretty stable overall.
Fun fact: Block 0´s timestamp is 2009-01-03 10:15 and block 1´s timestamp is 2009-01-08 18:54, so it took Satoshi Nakamoto +5 days to mine the first block. Check it here
The largest difficulty increase happened at block 68544 (2010-07-16) with +300%.
The largest difficulty decrease happened at block 689472 (2021-07-02) with -27.94%.
I hope you got a better understanding of difficulty and it´s great feature of securing 600 second block times.
Hash rate
Miners like to look at the hash rate to understand how many other online miners they are competing against. The hash rate can be described as numbers of hashes “guesses” per second in relation to mining. The higher the hash rate, the more competition.
To understand about the hash rate you have to understand it´s represented in Hashes per Second or H/s equals one double SHA-256 computation attempt.
The Bitcoin hash rate is a calculated numerical value that specifies an estimate of how many hashes are being generated by all Bitcoin miners trying to solve the current block or any given block. More about how to calculate it later.
All miners are competing to find the special hash value lower than the nonce, when they find it they get rewarded, it normally takes 10 min(600) to find this, as already discussed.
Since the Bitcoin blockchain have evolved a lot and have a lot of participants the hash rate has become super high.
The abbreviations are SI derived units representing the number of hashes performed in a one second time frame.
Let´s take a look at the current hash rate.
Let me explain.
The current block height in the graph is: 786240
The average hash rate was: 3.485999e+20 or 348.60 EH/s
That is a lot of hashes per seconds especially because the most efficient mining rig on the market currently offer a hash rate of 255 TH/s (Bitmain Antminer S19 XP HYD). Remember this graph from last blog post?
Let´s say everybody uses the most efficient mining rig (this is not true) on the market, how many mining rigs are then right now running according to block height 786240 ?
348,600,000,000,000,000,000 (348.60 EH/s) / 255,000,000,000,000 (255 TH/s) = 1,367,058 mining rigs would be online, the number is larger since not everybody uses this mining rig.
How to calculate hash rate
The hash rate can be calculated in different ways, it depends on what time-window you are looking at, is it the average hash rate over the last 6h, 12h, 24h, 7days, 14days?
So, you can see, the shorter time period, the more variance there will be. Same can be said with the mining rigs, they don´t offer a constant rate, there is variance. So, if you have a mining rig, try to look at the hourly, daily and weekly performance.
So, the hash rate is not a constant but varies a lot, you got to remember it´s a decentralized network, with millions of mining rigs connected, some only mine in specific time periods, some mines to help capture Gas flaring, some mines when there is sun or wind and so on.
You can check the hash rate here, but even better download your own full node and check how to get the info here.
The calculations
If you want to calculate the hash rate by yourself there are different ways it can be done.
The simplest formula, if you want to check the hash rate use this:
Hash Rate = Current Difficulty * 2^32 / 600
This formula is not saying anything about how many blocks have been mined in a period, but depend on the difficulty you have been giving in the block header.
Let´s try use the numbers written before in the article 4.871241e+13= difficulty
Hash rate = 48,712,410,000,000 * 2^32/600 = 3.48697e+20 = 348.697 EH
As you can see it´s not the same as mentioned in the earlier graph, but that´s because it was calculated differently here.
A more precise formula can be seen here.
If you want to check the last 36 blocks (6h) you could use this formula:
Hash Rate = (Blocks Found / Blocks Expected) * (Difficulty * 2^32) / 600
Let´s use the same difficulty as above, but in this period 38 blocks were mined.
Hash rate = (38/36) * 48,712,410,000,000 * 2^32/600 = 3.68069e+20 = 368.069 EH
As you can see there were two more blocks than expected in the last 6h, and this can be seen as a higher hash rate in this period.
Again it´s important to understand that miners/websites calculate the hash rate using different methods. The beauty with Bitcoin is that it´s permissionless (a public blockchain that allow anyone to participate in validating and mining transactions as well as using the system to buy, sell and trade assets), so nobody have to identify themselves so the hash rate is an estimate.
Factors that influence the hash rate variance
- Miners can come and go to the network.
- Mining rigs are not giving 100% accurate hashing power all the time.
- Hash rate readings depend on your time window.
- It´s a distributed network, so nodes might have a small latency in updating, but over time it guarantees consistency.
- Timestamps can be inconsistent (not often).
- Luck of the block. Sometimes people get lucky and find the nonce before the 600s block.
I hope you learned something new and now is the time to start mining if you have excess energy and want to produce your own secure decentralized money.
Powered by BTCPayWall