Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: genjix on June 29, 2011, 12:49:08 AM



Title: Deep block chain re-organisation
Post by: genjix on June 29, 2011, 12:49:08 AM
Hi,

What happens if there's a fork really deep?

getdata uses CBlockLocator for the starting hashes. If presented with an ending hash deep enough in the chain, then it will return blocks starting from that forked point in CBlockLocator. However re-requesting the next chunk of blocks (after the first 500 on the forked branch) won't happen because the difficulty hasn't increased enough yet to cause an internal block chain reorganisation and become the new main chain.

This seems to be the case since the starting point for getdata is always the head of the best chain in the code.

I guess this is one of those astronomically unlikely scenarios that it's not a worry. In that case it might be a point to artificially limit the amount of start hashes in getdata and save some bandwidth.


Title: Re: Deep block chain re-organisation
Post by: MoonShadow on June 29, 2011, 01:00:28 AM
Hi,

What happens if there's a fork really deep?


That's astronomicly unlikely to occur, but even if it did, all the clients have benchmarking hard coded into them that prevents them from going back and reorging beyond their latest benchmarked block.  The benchmarking basicly involves a list of block numbers chosen largely at random, and their established hash values.  If there is any kind of blockchain attack that tries to convince one or more clients that there is a differnet true chain, it must also be able to match hashs with these benchmarks as far back as they go, and not all of the clients have the same benchmarking list, so even diving into your own client to find the list to match won't necessarily mean that an attacker won't run into a client with a different benchmarked list.


Title: Re: Deep block chain re-organisation
Post by: ByteCoin on June 29, 2011, 01:18:24 AM
all the clients have benchmarking hard coded into them that prevents them from going back and reorging beyond their latest benchmarked block.

When MoonShadow says "benchmark" he means "checkpoint". From main.cpp...
Code:
bool CBlock::AcceptBlock()
{

...

    // Check that the block chain matches the known block chain up to a checkpoint
    if (!fTestNet)
        if ((nHeight ==  11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) ||

etc...

Also, the vanilla client has the checkpoints. There are other clients. I don't know whether they have checkpoints...

ByteCoin


Title: Re: Deep block chain re-organisation
Post by: genjix on June 29, 2011, 01:51:11 AM
Ah yes, I forgot about the checkpoints.


Title: Re: Deep block chain re-organisation
Post by: BeeCee1 on June 29, 2011, 02:58:31 AM
not all of the clients have the same benchmarking list, so even diving into your own client to find the list to match won't necessarily mean that an attacker won't run into a client with a different benchmarked list.
They seem to have the same list to me.  Newer versions have additional entries but once on the list they don't seem to change

List from 0.3.19:
nHeight
11111
33333
68555
70567
74000

List from 0.3.23:
nHeight
11111
33333
68555
70567
74000
105000
118000