Bitcoin Forum
May 30, 2024, 09:13:53 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Hash Target and Difficulty  (Read 231 times)
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 27, 2020, 04:19:00 AM
 #1

I want to confirm my understanding of Proof of work.  The below is all in base 10.

The range of numbers SHA256 can generate is from 0 to x where x= 115,792,089,237,316,195,423,570,985,008,687,907,853,269, 984,665,640,564,039,457,584,007,913,129,639,936  (1.15792E+77)

The current difficulty is y where y =17,557,993,035,167.31

So when a miner is Hashing the Block Header they must find a SHA256 result that is currently less than x / y = 6.59484E+63 correct?

Thank you
odolvlobo
Legendary
*
Offline Offline

Activity: 4340
Merit: 3248



View Profile
August 27, 2020, 06:25:46 AM
Last edit: August 27, 2020, 06:37:27 AM by odolvlobo
 #2

The range of numbers SHA256 can generate is from 0 to x ...

The current difficulty is y ...

So when a miner is Hashing the Block Header they must find a SHA256 result that is currently less than x / y ...

Not quite. The hash of a valid block must be less than or equal to the target value. The target value is recomputed each difficulty period, adjusting it depending on the time it takes to mine the last 2016 blocks.

The difficulty is computed from the target value like this: Difficulty = T1 / Target

where T1 = 0x00000000FFFF0000000000000000000000000000000000000000000000000000

Likewise, the target can be computed (approximately) from the difficulty like this: Target = T1 / Difficulty

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 27, 2020, 06:48:47 AM
Last edit: August 27, 2020, 07:00:20 AM by Picard78
 #3

Thank you for your response.

I read the following useful article and it also explains how the starting target and possible max_target = 0x00000000ffff0000000000000000000000000000000000000000000000000000

https://learnmeabitcoin.com/technical/target

From this article it appears that the Target is just a rolling calculation (every 2016 blocks) that relies on the previous Target and the ratio of the actual time against the expected time.

Quote
The difficulty is computed from the target value like this: Difficulty = T1 / Target

Hence the Difficulty is not involved in the Target calculation at all and is easily calculated.  

Difficulty = The # of hashes necessary to be performed on average to get a result below the Target value.

Also I just realized the Difficulty is not stored in the Block Header only the Difficulty Target is stored in the Block Header.

Thank you
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 27, 2020, 07:11:20 AM
 #4

The current difficulty is 17,557,993,035,167.31

But 1 PH/s is 1,000,000,000,000,000 hashes per second and the current network hash rate is 120 EH/s.

17,557,993,035,167.31
1,000,000,000,000,000

1 PH is > than current difficulty.   Hmmm.... that doesn't make sense.  I must still be missing something in my understanding.
odolvlobo
Legendary
*
Offline Offline

Activity: 4340
Merit: 3248



View Profile
August 27, 2020, 07:22:03 AM
 #5

The current difficulty is 17,557,993,035,167.31
But 1 PH/s is 1,000,000,000,000,000 hashes per second and the current network hash rate is 120 EH/s.
17,557,993,035,167.31
1,000,000,000,000,000
1 PH is > than current difficulty.   Hmmm.... that doesn't make sense.  I must still be missing something in my understanding.

The average number of hashes needed to mine a block is: 2256 / Target

This article might be helpful to you: https://en.bitcoin.it/wiki/Difficulty

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 27, 2020, 08:02:42 AM
Last edit: August 27, 2020, 10:57:29 AM by Picard78
 #6

Thank you.  I went for a swim and also realized my definition of Difficulty is wrong.

Difficulty= the number of times it's more difficult to mine the current block compared to T1.  A miner would need to perform 4,295,032,833 hashes on average to get a result below T1.

https://learnmeabitcoin.com/technical/longest-chain

The math works out well.

1.047391063 = (4295032833*17557993035167.3)/(120000000000000000000)/600
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 28, 2020, 09:55:28 AM
 #7

I am now studying the Nonce field in the Block Header.

It took on average 4,295,032,833 Hashes to go below T1.   The largest value that can fit in the Nonce Block Header field is 4,294,967,295.

Which means right from the start of Bitcoin, Satoshi wanted Miners to change the Coinbase Data field to include extra nonce values which results in recalculating the Merkle root and the process starts again for the next 4 Billion hashes.

Satoshi's priority was to keep the size of the Block Header at 80 Bytes I guess.  I'm just surprised he didn't make the Nonce field a little bigger (64 bits) to make the Mining process a little more straight forward at the start of Bitcoin's life cycle.



ranochigo
Legendary
*
Offline Offline

Activity: 2982
Merit: 4193



View Profile
August 29, 2020, 11:23:42 AM
 #8

I am now studying the Nonce field in the Block Header.

It took on average 4,295,032,833 Hashes to go below T1.   The largest value that can fit in the Nonce Block Header field is 4,294,967,295.

Which means right from the start of Bitcoin, Satoshi wanted Miners to change the Coinbase Data field to include extra nonce values which results in recalculating the Merkle root and the process starts again for the next 4 Billion hashes.

Satoshi's priority was to keep the size of the Block Header at 80 Bytes I guess.  I'm just surprised he didn't make the Nonce field a little bigger (64 bits) to make the Mining process a little more straight forward at the start of Bitcoin's life cycle.
Given how it existed from the start and he envisioned a system with one-cpu-one-vote, it's not hard to see why it isn't that much bigger. He probably didn't expect Bitcoin to shift from CPU to GPU and to ASICs nor pooled mining.

It's pretty interesting but in the first stage of Bitcoin, extranonce proved to be a way for people to be able to track the miners. ExtraNonce increased in a predictable way which is also the reason how people manage to identify the potential satoshi addresses.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 29, 2020, 11:59:38 AM
 #9

Quote
Given how it existed from the start and he envisioned a system with one-cpu-one-vote, it's not hard to see why it isn't that much bigger.

But right from the start, around half the time the Golden Nonce would be out of bounds requiring the use of the ExtraNonce and recalculating the Merkle Root.  This is a little peculiar to me.  However, Satoshi must of had his reasons.

Quote
He probably didn't expect Bitcoin to shift from CPU to GPU and to ASICs nor pooled mining.

Hmmmm.... that means Satoshi probably didn't anticipate the price of bitcoin reaching $10,000 in 10 years?

Quote
It's pretty interesting but in the first stage of Bitcoin, extranonce proved to be a way for people to be able to track the miners. ExtraNonce increased in a predictable way which is also the reason how people manage to identify the potential satoshi addresses.

Miners would have large ExtraNonce values compared to regular CPU machines and this was a good indicator of the increase in Miners vs hobbyists?
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
August 29, 2020, 10:48:45 PM
Merited by ranochigo (1)
 #10

Given how it existed from the start and he envisioned a system with one-cpu-one-vote, it's not hard to see why it isn't that much bigger. He probably didn't expect Bitcoin to shift from CPU to GPU and to ASICs nor pooled mining.

There was a comment in one of the early emails purported to be from Satoshi Nakamoto where here said:
At first, most users would run network nodes, but as the network grows beyond a certain point, it would be left more and more to specialists with server farms of specialized hardware. A server farm would only need to have one node on the network and the rest of the LAN connects with that one node.

If that email is indeed from Satoshi, then it would seem that they were fully aware of, and expecting, that mining would end up the domain of "farms".

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
pooya87
Legendary
*
Offline Offline

Activity: 3472
Merit: 10605



View Profile
August 30, 2020, 03:55:56 AM
 #11

I'm just surprised he didn't make the Nonce field a little bigger (64 bits) to make the Mining process a little more straight forward at the start of Bitcoin's life cycle.

there is just no point when you can use the extranonce easily while keeping every field in header similar 32-bit integers. besides using a 64-bit nonce is not compatible with using SHA256 which uses 32-bit integers and could potentially create bugs. right now you simply place the same nonce value inside one of the SHA256 working vector items inside its second block and simply increment that to perform the compression on each round. with 64-bit you would have to split it into two and place each part in a different item and then keep track of the increments and jump between the two items.
in other words UInt64 would only make more code complexity without gaining anything in the long run. while having UInt32 and changing something else from the start is highly scalable.

P.S. there is no merkle root computation in majority of early blocks since they have only 1 tx and merkle root is the hash of that tx.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
ranochigo
Legendary
*
Offline Offline

Activity: 2982
Merit: 4193



View Profile
August 30, 2020, 05:02:49 AM
 #12

Hmmmm.... that means Satoshi probably didn't anticipate the price of bitcoin reaching $10,000 in 10 years?
Realistically, in 2009, I don't think most people did.

Miners would have large ExtraNonce values compared to regular CPU machines and this was a good indicator of the increase in Miners vs hobbyists?
IMO, yes. That's one way to interpret it though there might be other reasons why he included it. It's not defined in the protocol either.
At first, most users would run network nodes, but as the network grows beyond a certain point, it would be left more and more to specialists with server farms of specialized hardware. A server farm would only need to have one node on the network and the rest of the LAN connects with that one node.

If that email is indeed from Satoshi, then it would seem that they were fully aware of, and expecting, that mining would end up the domain of "farms".
CPU mining is so inefficient that I doubt even a farm of CPUs could outpace a GPU by itself. For the nonce field to be full utilised, it would need around 4GH/s and that would really require quite a big farm of CPUs. I think the main concern at that time was with botnets actually, doubt the operation of server farms would outpace botnets.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!