Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: jimbobway on April 19, 2011, 03:15:50 PM



Title: Easy Way To Detect Bitcoin Fork?
Post by: jimbobway on April 19, 2011, 03:15:50 PM
I hear about this all the time...the chain forking...what's the easiest way to detect a fork?  Can someone develop this and put it on a website?


Title: Re: Easy Way To Detect Bitcoin Fork?
Post by: Cdecker on April 19, 2011, 04:35:52 PM
A fork is not easy to detect. It is the consequence of a network partition which can be caused by ad luck or a connectivity problem (chinas firewall blocks bitcoin traffic => fork). If a fork happens the networks might rejoin again later, discarding the shorter chain (probably the smaller partition).
Structuring the network might be a first step towards a partition tolerant network but currently there's no easy way.


Title: Re: Easy Way To Detect Bitcoin Fork?
Post by: theymos on April 19, 2011, 05:57:11 PM
With network segmentation, blocks will be produced more slowly. There will also be a large reorg after the network recombines, which is detectable.


Title: Re: Easy Way To Detect Bitcoin Fork?
Post by: MoonShadow on April 19, 2011, 06:34:41 PM
I hear about this all the time...the chain forking...what's the easiest way to detect a fork?  Can someone develop this and put it on a website?

What kind of fork?  If you mean a network split, a seperate 'watchdog' process can detect when the intervel between blocks suddenly doubles, and issue a warning.  Each successive block that is over 80% longer than the prior average increases the certainty that a network split has occurred, and that you are likely on the wrong side of it.  If you are on the majority side, it doesn't really matter.

If you mean a blockchain split, then such a event can be detected by the clients because some of the clients will receive two valid blocks, and has to keep both until the next block is created, which then breaks the tie by being built off of one or the other.  The loser is discarded.


Title: Re: Easy Way To Detect Bitcoin Fork?
Post by: Mike Hearn on April 19, 2011, 07:09:57 PM
You can run bitcoin -printblocktree then look in debug.log to see any chain splits your client observed. My copy has seen three throughout its lifetime, all of them only a single block long.


Title: Re: Easy Way To Detect Bitcoin Fork?
Post by: Raulo on April 19, 2011, 07:51:18 PM
You can run bitcoin -printblocktree then look in debug.log to see any chain splits your client observed. My copy has seen three throughout its lifetime, all of them only a single block long.

It seems low. All invalid blocks are a single block splits. Whenever such a block is deemed invalid by the bitcoin program (because an alternative forked tree grew longer) and transactions are merged into the current tree, bitcoin prints "REORGANIZE" into debug.log. I grepped 4 such instances in April only. There should have been been more because my deamon may have picked the "correct" tree and didn't need to reorganize anything.


Title: Re: Easy Way To Detect Bitcoin Fork?
Post by: TiagoTiago on April 19, 2011, 09:34:20 PM
Detecting the split while it is happening and after the forks are being merged are two different things


Title: Re: Easy Way To Detect Bitcoin Fork?
Post by: Raulo on April 19, 2011, 09:53:39 PM
Detecting the split while it is happening and after the forks are being merged are two different things

Not very much unless the fork is hidden and grown independently of the network. If you have a well connected bitcoin daemon, it usually receives information about both the forking blocks from the network. It's now just a matter of checking ancestry of the blocks.


Title: Re: Easy Way To Detect Bitcoin Fork?
Post by: TiagoTiago on April 19, 2011, 11:12:39 PM
Perhaps with should be talking about short term and long term forks