Difference between revisions of "Target"
Angus Adams (talk | contribs) |
|||
(15 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | '' | + | The '''target''' is a 256-bit number that all Bitcoin clients share. The double SHA-256 [https://wiki.bitcoinsv.io/index.php/Mining#Hashing hash] of a [[Block hashing algorithm|block's header]] must be less than or equal to the current target for the block to be accepted by the network. The lower the target, the more [[difficulty|difficult]] it is to generate a block. |
− | + | It's important to realise that block generation is not a long, set problem (like doing a million hashes), but more like a lottery. Each hash is a random number between 0 and the maximum value of a 256-bit number (2^256-1). If a hash is below the target, the node wins. If not, you increment the nonce (completely changing the hash) and try again. | |
− | + | The Bitcoin network tries to produce one block every ten minutes on average. As mining hash power changes over time, it achieves this through changing the target value. | |
− | + | Historically (prior to forking from BTC in August 2017), Bitcoin changed its target every 2016 blocks (exactly two weeks if a block time of 10 minutes was kept perfectly). This change in the target is known as a 'difficulty adjustment'. Under the original difficulty adjustment paradigm, when adjusting the target, every Bitcoin client compared the actual time it took to generate 2016 blocks with the two week goal and modified the target by the percentage difference. A single retarget never changes the target downwards (increasing difficulty) by more than a factor of 4, or upwards (decreasing difficulty) by more than a factor of 0.75. This prevents large changes in difficulty. | |
− | + | After the duplication of the Bitcoin transaction ledger by operators of the BTC network in August 2017, Bitcoin's original difficulty adjustment algorithm was changed to what was named the Emergency Difficulty Adjustment (EDA) algorithm. The EDA had the capacity to update the target value every time a new block was found (as opposed to every 2016 blocks), while still targeting a ten minute block time average. The EDA was changed to the Difficulty Adjustment Algorithm (DAA) on 17 November 2017 to address instabilities associated with the EDA. The DAA uses a moving average of the last 144 blocks to determine changes to the target and like the EDA, the target can change every block. A single DAA retarget never changes the target downwards (increasing difficulty) by more than a factor of 2, or upwards (decreasing difficulty) by more than a factor of 2. This sets the maximum bounds for any change in difficulty. | |
− | + | The reason the EDA (and later the DAA) needed to be implemented was due to the creation of the competing BTC network which was expected to garner significantly more hash power than Bitcoin (known as Bitcoin Cash at the time). These measures were put in place so that block production could remain relatively stable due to Miners' ability to instantaneously re-allocate hash between the networks. | |
− | + | It is proposed that Bitcoin will move back to the original difficulty adjustment algorithm (still used by Bitcoin Core - BTC) in the future. | |
− | |||
− | It is proposed that | ||
===How is the target stored in blocks?=== | ===How is the target stored in blocks?=== | ||
− | Each block stores a packed representation in its block header (called [[Block hashing algorithm|Bits]]) for its actual hexadecimal target. The target can be derived from Bits via a predefined formula. For example, if the packed target in the block is 0x1b0404cb, the hexadecimal target is: | + | Each block stores a packed representation in its block header (called [[Block hashing algorithm|Bits]]) for its actual [[hexadecimal]] target. The target can be derived from Bits via a predefined formula. For example, if the packed target in the block is 0x1b0404cb, the hexadecimal target is: |
− | 0x0404cb | + | 0x0404cb x 256^(0x1b - 3) = 0x00000000000404CB000000000000000000000000000000000000000000000000 |
Note that the 0x0404cb value is a signed value in this format. The largest legal value for this field is 0x7fffff. To make a larger value you must shift it down one full byte. Also 0x008000 is the smallest positive valid value. | Note that the 0x0404cb value is a signed value in this format. The largest legal value for this field is 0x7fffff. To make a larger value you must shift it down one full byte. Also 0x008000 is the smallest positive valid value. | ||
+ | |||
+ | === What is the current target? === | ||
+ | Check the [[Block hashing algorithm|Bits]] field of the most recent block on a [https://whatsonchain.com/ block explorer]. | ||
=== What is the maximum target? === | === What is the maximum target? === | ||
Line 34: | Line 35: | ||
See also [[Difficulty]] | See also [[Difficulty]] | ||
− | + | ==Attribution== | |
− | + | This content is based on content sourced from https://en.bitcoin.it/wiki/Target under [https://creativecommons.org/licenses/by/3.0/ Creative Commons Attribution 3.0]. Although it may have been extensively revised and updated, we acknowledge the original authors. |
Latest revision as of 07:05, 6 May 2023
The target is a 256-bit number that all Bitcoin clients share. The double SHA-256 hash of a block's header must be less than or equal to the current target for the block to be accepted by the network. The lower the target, the more difficult it is to generate a block.
It's important to realise that block generation is not a long, set problem (like doing a million hashes), but more like a lottery. Each hash is a random number between 0 and the maximum value of a 256-bit number (2^256-1). If a hash is below the target, the node wins. If not, you increment the nonce (completely changing the hash) and try again.
The Bitcoin network tries to produce one block every ten minutes on average. As mining hash power changes over time, it achieves this through changing the target value.
Historically (prior to forking from BTC in August 2017), Bitcoin changed its target every 2016 blocks (exactly two weeks if a block time of 10 minutes was kept perfectly). This change in the target is known as a 'difficulty adjustment'. Under the original difficulty adjustment paradigm, when adjusting the target, every Bitcoin client compared the actual time it took to generate 2016 blocks with the two week goal and modified the target by the percentage difference. A single retarget never changes the target downwards (increasing difficulty) by more than a factor of 4, or upwards (decreasing difficulty) by more than a factor of 0.75. This prevents large changes in difficulty.
After the duplication of the Bitcoin transaction ledger by operators of the BTC network in August 2017, Bitcoin's original difficulty adjustment algorithm was changed to what was named the Emergency Difficulty Adjustment (EDA) algorithm. The EDA had the capacity to update the target value every time a new block was found (as opposed to every 2016 blocks), while still targeting a ten minute block time average. The EDA was changed to the Difficulty Adjustment Algorithm (DAA) on 17 November 2017 to address instabilities associated with the EDA. The DAA uses a moving average of the last 144 blocks to determine changes to the target and like the EDA, the target can change every block. A single DAA retarget never changes the target downwards (increasing difficulty) by more than a factor of 2, or upwards (decreasing difficulty) by more than a factor of 2. This sets the maximum bounds for any change in difficulty.
The reason the EDA (and later the DAA) needed to be implemented was due to the creation of the competing BTC network which was expected to garner significantly more hash power than Bitcoin (known as Bitcoin Cash at the time). These measures were put in place so that block production could remain relatively stable due to Miners' ability to instantaneously re-allocate hash between the networks.
It is proposed that Bitcoin will move back to the original difficulty adjustment algorithm (still used by Bitcoin Core - BTC) in the future.
How is the target stored in blocks?
Each block stores a packed representation in its block header (called Bits) for its actual hexadecimal target. The target can be derived from Bits via a predefined formula. For example, if the packed target in the block is 0x1b0404cb, the hexadecimal target is:
0x0404cb x 256^(0x1b - 3) = 0x00000000000404CB000000000000000000000000000000000000000000000000
Note that the 0x0404cb value is a signed value in this format. The largest legal value for this field is 0x7fffff. To make a larger value you must shift it down one full byte. Also 0x008000 is the smallest positive valid value.
What is the current target?
Check the Bits field of the most recent block on a block explorer.
What is the maximum target?
The maximum target used by SHA256 mining devices is:
0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Because Bitcoin stores the target as a floating-point type, this is truncated:
0x00000000FFFF0000000000000000000000000000000000000000000000000000
The maximum target is the target used in the Genesis Block and represents a difficulty of 1. Its packed representation as Bits is 0x1d00ffff.
Since a lower target makes Bitcoin generation more difficult, the maximum target is the lowest possible difficulty.
Related Links
See also Difficulty
Attribution
This content is based on content sourced from https://en.bitcoin.it/wiki/Target under Creative Commons Attribution 3.0. Although it may have been extensively revised and updated, we acknowledge the original authors.