Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: btcrich on July 07, 2013, 09:40:48 AM



Title: Time it takes to accept new chain and reorganize blocks
Post by: btcrich on July 07, 2013, 09:40:48 AM
When broadcasting a new chain to the network that would reorganize perhaps only the 10 last blocks, the network accepts it within the next 1-2 next blocks.

However, when I broadcast a chain that reorganizes the last 300 or so blocks, it takes significantly longer for the network to finally accept this chain.

Why does it take longer when reorganizing a larger number of blocks?


Title: Re: Time it takes to accept new chain and reorganize blocks
Post by: TierNolan on July 07, 2013, 10:04:52 AM
Why does it take longer when reorganizing a larger number of blocks?

More data needs to be sent, possibly.

The way the system works is that clients only forward blocks when they are added to the main chain.

So, if the chain was

A1 <- B1 <- C1 <- D1

and the client received B2, then it just stores B2 in RAM and doesn't forward it.  If you then send C2, that is again not forwarded.

Once you finally send E2, the alt chain becomes the longest.  This means B2, C2, D2 and E2 are all added to the main block chain and the client broadcasts all blocks to its neighbours.

They then have to do the same thing.

The effect is that you have to send all 300 blocks to all peers before any of them will forward any of them.

With enough blocks the other client might even run out of RAM, so not store all 300.


Title: Re: Time it takes to accept new chain and reorganize blocks
Post by: btcrich on July 07, 2013, 10:59:26 AM
Interesting.  This makes sense but I'm assuming there's a little more to it.

I believe this implies that the peer does not calculate the sum of all difficulties of the new chain until it has downloaded it completely?  Although not very efficient, I imagine a malicious user could take down peers this way.


Title: Re: Time it takes to accept new chain and reorganize blocks
Post by: TierNolan on July 07, 2013, 12:21:12 PM
I believe this implies that the peer does not calculate the sum of all difficulties of the new chain until it has downloaded it completely?  Although not very efficient, I imagine a malicious user could take down peers this way.

I am not sure.  It might forward block headers (80 bytes) once the headers prove the longest chain.


Title: Re: Time it takes to accept new chain and reorganize blocks
Post by: gmaxwell on July 07, 2013, 05:22:03 PM
Can you elaborate a little more on exactly how and what you're testing here?


Title: Re: Time it takes to accept new chain and reorganize blocks
Post by: btcrich on July 07, 2013, 06:09:25 PM
Can you elaborate a little more on exactly how and what you're testing here?


I am experimenting with reorganizing past blocks in a chain.  I've noticed that the time it takes for my chain to be accepted by the network increases with the number of blocks I try to reorganize.  Obviously I'm testing this on a private chain of which I'm connected to 3-4 peers out of a total of about 10 peers on the network.  I have ~70% of the network hash rate.