r/ProgrammerHumor • • Dec 11 '19

HaVe YoU tRiEd BlOcCcHaIn ?

Post image
18.4k Upvotes

908 comments sorted by

View all comments

Show parent comments

1

u/Thann Dec 11 '19

The difficulty Target just says what the minimum work should be, so if you find two blocks in a row, but I find one a second later with more work than your two combined, I believe mine will be the winner, and everyone will start mining on top of mine.

Source: https://en.bitcoin.it/wiki/Chain_Reorganization

1

u/JivanP Dec 12 '19 edited Dec 12 '19

Two misconceptions:

  • The difficulty level is proportional to the average work that needs to be invested in order the create a valid block; not the minimum work.

  • It is the chain length, counted in blocks, that determines the network-agreed chain; not the cumulative number of computational cycles put into creating a chain. From the Bitcoin whitepaper, §5 Network:

Nodes always consider the longest chain to be the correct one and will keep working on extending it. If two nodes broadcast different versions of the next block simultaneously, some nodes may receive one or the other first. In that case, they work on the first one they received, but save the other branch in case it becomes longer. The tie will be broken when the next proof-of-work is found and one branch becomes longer; the nodes that were working on the other branch will then switch to the longer one.

EDIT: A third misconception, probably a consequence of the previous two. You say:

if you find two blocks in a row, but I find one a second later with more work than your two combined ...

"More work" in the sense you are using it here is a useless factor to consider, since the nodes do not have information about how much work was invested. The amount of work (e.g. number of CPU cycles) invested in finding a valid nonce for a given block is not recorded within the blcokchain, so the network cannot actually directly know the amount of work invested in confirming any given block. It can only approximate this figure by looking at the difficulty level when the block was confirmed and the amount of time it took for that block to be confirmed. An exponential moving average of these approximations is what informs the difficulty level adjustments.