Bitcoin Forum
June 23, 2018, 07:10:50 AM
 News: Latest stable version of Bitcoin Core: 0.16.1  [Torrent]. (New!)
 Home Help Search Donate Login Register
 Pages: [1]
 Author Topic: Cumulative difficulty shouldn't be used to choose the "main" blockchain  (Read 2274 times)
Come-from-Beyond
Legendary

Offline

Activity: 1988
Merit: 1007

Newbie

 October 12, 2013, 01:28:28 PM

Let's assume that we have a cryptocoin with a 3-block retarget period and 10 minutes between blocks.

A first blockchain looks like:

0th block: timestamp 00:00, difficulty 1   <- first block after retarget
1st block: timestamp 00:05, difficulty 1
2nd block: timestamp 00:10, difficulty 1
3rd block: timestamp 00:20, difficulty 2   <- first block after retarget
4th block: timestamp 00:30, difficulty 2
5th block: timestamp 00:40, difficulty 2

Cumulative difficulty = 1 + 1 + 1 + 2 + 2 + 2 = 9
Hashes calculated (excluding 0th block) = N + N + 2N + 2N + 2N = 8N
Time spent = 00:40 - 00:00 = 40 minutes
Hashpower wasted = 8N / 40 = 0.2N hash/min

A second one looks like:

0th block: timestamp 00:00, difficulty 1   <- first block after retarget
1st block: timestamp 00:10, difficulty 1
2nd block: timestamp 00:20, difficulty 1
3rd block: timestamp 00:30, difficulty 1   <- first block after retarget
4th block: timestamp 00:40, difficulty 1
5th block: timestamp 00:50, difficulty 1
6th block: timestamp 01:00, difficulty 1   <- first block after retarget
7th block: timestamp 01:10, difficulty 1
8th block: timestamp 01:20, difficulty 1

Cumulative difficulty = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 9
Hashes calculated (excluding 0th block) = N + N + N + N + N + N + N + N = 8N
Time spent = 01:20 - 00:00 = 80 minutes
Hashpower wasted = 8N / 80 = 0.1N hash/min

Which blockchain is better? If you take into account the cumulative difficulty you can choose the second one, which looks a bad choice coz it requires hardware with lower "intensity" of hashing. But if we took squares of the difficulty of each block we would definitely choose the first blockchain (15 vs 9).

You may ask why squares? Well... I think there is a mystical connection to http://en.wikipedia.org/wiki/Least_squares.
1529737850
Hero Member

Offline

Posts: 1529737850

Ignore
 1529737850

1529737850
 Report to moderator
1529737850
Hero Member

Offline

Posts: 1529737850

Ignore
 1529737850

1529737850
 Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1529737850
Hero Member

Offline

Posts: 1529737850

Ignore
 1529737850

1529737850
 Report to moderator
jl2012
Legendary

Offline

Activity: 1792
Merit: 1010

 October 12, 2013, 02:01:29 PM

Fail 1: 00:60 = 01:00

Fail 2: Just extend one more block and the first chain will win

-----------------------

To others: don't feed the troll. I stop here

PGP: D3CC 1772 8600 5BB8 FF67 3294 C524 2A1A B393 6517
Come-from-Beyond
Legendary

Offline

Activity: 1988
Merit: 1007

Newbie

 October 12, 2013, 02:10:25 PM

Fail 1: 00:60 = 01:00

Fixed, thx. But this doesn't change the result.

Fail 2: Just extend one more block and the first chain will win

What if I extended the second chain? Try to read my post instead of skimming over it.

To others: don't feed the troll. I stop here

To others: jl2012 is obviously a forum addict. He sees trolls everywhere.
pmlyon
Member

Offline

Activity: 72
Merit: 10

 October 12, 2013, 03:53:35 PM

I think the problem is that you are comparing two different timestamps. The first blockchain wouldn't stop mining at the 00:40 mark, so if you continue it to the 01:20 mark it will win as it should.

Author of BitSharp, a C# Bitcoin node
https://github.com/pmlyon/BitSharp/wiki
Come-from-Beyond
Legendary

Offline

Activity: 1988
Merit: 1007

Newbie

 October 12, 2013, 04:19:07 PM

I think the problem is that you are comparing two different timestamps. The first blockchain wouldn't stop mining at the 00:40 mark, so if you continue it to the 01:20 mark it will win as it should.

Maybe... That was just an idea. Everything in our world can be modelled with the Gaussian distribution. When you try to optimize such models you usually come to "least squares".
 Pages: [1]