8
2
Currently, target is stored in each block. Why is that? Why it is not simply computed by each client based on the previous timestamps from previous blocks? Why it has to be stored within the block?
In other words, doesn't allowing miner to choose the target remove that it is exponentially harder to create a new block? Other miners might have to mine 256 consequent blocks, but I have only to be lucky once and get one block with 8 more zeroes to replace those 256 blocks. While it is less probable, it grows linearly (256x less probable) and not exponentially.
Sorry for beating the dead horse. May I know why there's no more reason to include the target in each block? Thanks – Viet – 2017-10-24T17:46:29.687
Name me a reason why it would be needed? – Pieter Wuille – 2017-10-24T19:33:59.703
Sorry, I'm new to this so I'm sitting on the fence and trying to understand how removing the target improves the current design. I didn't mean to challenge or question your judgement. Thanks. – Viet – 2017-10-25T09:19:03.957
1I didn't mean to offend, and didn't say it improves the design - it's just unnecessary now. You're asking why is it no longer needed. I explained why it used to be needed (contextless validation of headers) and why that doesn't apply anymore (headers-first synchronization since 0.10). The only (known) reason it was needed is gone, so it's not needed anymore. – Pieter Wuille – 2017-10-25T09:27:28.417
1
Could you please reference the code which validates the target to match a correct difficulty. I can't find it. I can only see that nodes check the range of the target value. https://github.com/bitcoin/bitcoin/blob/master/src/pow.cpp#L74
– Dieter Pisarewski – 2018-04-03T11:08:08.353@DieterPisarewski The code should be in the
– yaobin – 2018-10-17T01:45:16.290ContextualCheckBlockHeaderfunction. The line you gave above seems to be used in the "contextless" block check.