the timeless question : bitcoin mining difficulty (with some math this time)

7 replies 187 views
matrix51Member
Posts: 4 · Reputation: 54
#1Apr 19, 2025, 07:14 AM
Let’s say we want to mine the next block after block No.749256, which has this hash: 00000000000000000009b06cb40e4302fc0dab3f8031f058351e904e14be2b45. > the current difficulty is 19 leading zeros (that’s 76 zero bits=19*4) out of 256 > the total size of the population is N=2^256 In big-endian format, the result of double_sha256 should end with 76 zeros. This means the first 180 bits can be anything. > total possible solutions is K=2^180 Let’s assume we’re using one Antminer S19 PRO with a hash rate of 110TH/s for 10 minutes. > total attempts would be n=66*10^15 We only need one double_sha256 result that meets the difficulty requirement. > k=1 To break down the mining issue, here are the numbers we need to figure out the probability of mining a block in 10 minutes: N is the population size = 2^256 n is the number of attempts (double_SHA256 checks) = 66*10^15 K is the number of successful outcomes in the population = 2^180 k is the number of successes we want = 1 This is a probability problem tackled with hypergeometric distribution (you can check the definition on Wikipedia). The calculation formula is on Wikipedia too. Can anyone help me crunch these numbers for the example I’ve shared? The values seem way too large to handle with Python or Matlab. I came across some references to an older post about mining difficulty, but it didn’t really cover this in detail.
4 Reply Quote Share
LuckyCoinLegendary
Posts: 832 · Reputation: 4795
#2Apr 19, 2025, 10:03 AM
No floating-point software will be able to calculate with those two numbers, because one is an order of magnitude larger than the other. Try using a fixed-point library - it shouldn't use up so much memory, but the execution time will become longer.
5 Reply Quote Share
roguegwe1Member
Posts: 9 · Reputation: 179
#3Apr 19, 2025, 02:59 PM
Fuck formulas in this case and in many other they are simply not practical. This problem is far easier to solver without complex formulas. First all diff is set in stone for about 2 weeks. So look up difficulty. so current diff is a fixed number 28.17t you hash rate is a fixed number 100th the actual unknown number is the net works current hashrate.  And now that the network is huge no one ever knows the exact size of the gear hashing = Fact so look up 'current' hash rate chart's  which are always approximate https://www.coinwarz.com/mining/bitcoin/hashrate-chart and from Aug 6 to Aug 13 the lowest 'guess' was  186.7288eh the highest 'guess' was 253.9883eh So the answer to your question is 100th/186728800th on the low hashrate to 100th/253988300th on the high hashrate end 1867288 to 1 shot ranging to 2539883 to 1 shot An easy way to see it is below: Last jump the world had 1ph of gear 10 s19's that do 100th So what are the odds for 1 machine to hit next block 1 of 10 easy peasy if the net work stays at 1ph. but a large expansion alters the hash rate and now even though diff is frozen for 2 weeks. hash is not so  4 new units mean 1.4 ph gear and the 1 s19 has a 1/14 shot to hit the block. " ... To sum up the mining problem, here are the parameters to calculate the probability of mining a block in 10 min :   N is the population size                                                            =  2^256   n is the number of draws (double_SHA256 checks)                     = 66*10^15   K is the number of known success states in the population          = 2^180   k is the number of wanted successes                                         = 1... " My solve is not a true solve of your problem as you are setting the 10 minute limit and you want to know 2 things your machine getting the next block and doing it in 10 minutes My solve is only for my 100 th s19 getting the next block on 0 time to endless time Reality is who really cares about the 10 minutes if you gear makes the block in 9 minutes or 11 minutes you still make the block. I get a range 1/1867288-1/2539883 that I win the "next block" with my lone s19  and I do not care if I do it in 10 minutes. Still your question is interesting
2 Reply Quote Share
its_ninjaSenior Member
Posts: 269 · Reputation: 1259
#4Apr 19, 2025, 05:30 PM
Simple math. What's the expected chance a miner of X TH/s getting a block in 10 minutes. Miner does: D = X * 10^12 / (2^32) Diff per second In 10 minutes it does D10 = D * 600 Diff What is the current Network Diff? (i.e. the 'expected' amount of total network Diff per 10 minutes) ND = 28351606743493.8 (which you can calculate from the hex value which is "0x1709ed88") So what is your expected chance of getting a block in 10 minutes?  D10 / ND Or 1 in (ND / D10) However, your question suggests that the 10 minute figure affects the result. The only effect it has is to increase D -> D10 i.e. multiply D by 600. Mining is a simple random occurrence with simple calculations: Blocks are expected every: 'Number of Attempts' / (ND*(2^32)) Since 1Diff = 2^32 attempts However, if that 'every' is more than 2 weeks then no it doesn't work. Since ND is no longer a constant. You cannot determine even the next value of ND in advance.
6 Reply Quote Share
matrix51Member
Posts: 4 · Reputation: 54
#5Apr 20, 2025, 08:52 PM
Thanks @kano, @a1 Hashrate LLC2022, @NotATether. My intention was also to have a post that anyone googling mining difficulty can find. I recommend these two articles that studied statistically the mining difficulty problem : - https://www.zora.uzh.ch/id/eprint/173483/1/SSRN-id3399742-2.pdf - https://doi.org/10.2139/ssrn.3399742 Conclusion is that the Hypergeometric Distribution is the correct model and not Poisson Distribution as commonly accepted (also assumed in Satochi's white paper). Nevetheless, I agree that the way I stated the problem is incomplete. We should also do the calculation "knowing that" there is competition with X hash power. Overall, I agree that the ratio of own hash power to the network hash power can be a good approximation.
2 Reply Quote Share
its_ninjaSenior Member
Posts: 269 · Reputation: 1259
#6Apr 22, 2025, 12:15 PM
My calc is the exact expected result, not an approximation. The reason it is, is because the question is exactly the same as asking what is the expected number of 6's rolled on a dice. The answer is: 'attempts' / 6 Same for mining: 'attempts' / (ND * (2^32)) ND is currently f(0x1709ed88) where f(x) uses only constants (other than x) So yeah there is no difference except the size of the numbers. -- Edit: oh one more thing, competition plays no part in block finding probability.
3 Reply Quote Share
eric_diamondFull Member
Posts: 99 · Reputation: 687
#7Apr 24, 2025, 02:44 AM
Hey guys, i've been always trying to figure out how exactly the mining process works with bitcoin but always failed to understand it. All i know that the block hash should have a lot of zeros but what hashes what to get this value is what i am trying to understand. I have googled, watched YouTube, but still i can't get it well enough. i would really be thankful if someone can explain to me in a easy way on how the mining process works with the following example block number 750452: It's block hash is: 0000000000000000000420d2e347f016f63d9045b7895589e5eff33893cf833f Merkle root: ef108a25a975f6c2f5528e0e1b2d4162686a8f878a0ca9b40e59d1845d8c9798 Nonce: 263795775 previous block hash: 000000000000000000084d88e5ac59edd7c34c20d6b5addf18aae6f1040ac215 Now can anyone explain for me please?
3 Reply Quote Share
matrix51Member
Posts: 4 · Reputation: 54
#8Apr 24, 2025, 08:36 AM
Simply the concatenation of (version+previous_hash+merkle_root+tim_stamp+target_difficulty+nonce) called candidate block header should give the right target number of leading zeros after applying double_sha256. If you are asking about the theory, here is a link to understand step by step how to build a header. I've never found anything giving a better explanation to start with :  https://medium.com/fcats-blockchain-incubator/understanding-the-bitcoin-blockchain-header-a2b0db06b515 It's just the theory behind the process for bitcoin. In reality folks use dedicated hardware (asics) and thousands of them to have any chance of succeeding before the others. The discussion in this post was about the probability of success.
3 Reply Quote Share

Related topics