Pages:
Author

Topic: What EXACTLY means "longest" chain ? - page 2. (Read 2732 times)

legendary
Activity: 1072
Merit: 1181
July 10, 2011, 09:20:31 AM
#8
The longest chain is defined as the one with the most proof-of-work.

Technically, the "length" of each chain is the sum of (2^256 divided by the block's target) for a given block plus all its ancestors.
This number is the statistically expected number of hashes to have been performed in the chain, and is currently equal to about 4.1e19 (41 billion billion).
full member
Activity: 195
Merit: 100
July 10, 2011, 07:58:12 AM
#7
Nodes process which ever "longest chain" they hear about first. 

Yup. Of course.

I did not phrase the question clearly enough. I was thinking of the following situation: A node is booted, bitcoind is started...reads the disc files and finds a block index where there are TWO longest chains. The program will prefer one of them. Which one will it prefer? I was not able to find that answer. I now realize, that it is in fact not really important. And I realize that I will have to spend a day or two understanding block reorganization... :-)

Actually, the terminology of longest chain is ill defined. There can be several chains of maximal length.

And again: If this thing (bitcoind) should eventually takle over management of my money - I want to make sure, as computer scientist, I understand every single bit of what it does.  Smiley
full member
Activity: 195
Merit: 100
July 10, 2011, 07:53:16 AM
#6
...

Thank you, Joel, for your help ! It clarified the issue.
newbie
Activity: 59
Merit: 0
July 09, 2011, 08:38:55 PM
#5
Assume, 1/2 of the nodes pick GENESIS-A-B-C and the other 1/2 of the nodes pick GENESIS-A-X-Y. In this case the "battle" for the right correct chain might take much longer.

Not really, the "battle" should be over pretty fast in any case, as the next block settles the issue.
There is of course the chance that the next two blocks are found at proximately the same time and the split continues, but the chances for this to happen are pretty slim.
legendary
Activity: 1596
Merit: 1012
Democracy is vulnerable to a 51% attack.
July 09, 2011, 08:36:50 PM
#4
Ok. What happens if there are two longest chains.
Then the choice of chain is arbitrary. Eventually one chain will become longer and the problem will solve itsef.

Quote
Well, this is not a problem for the future of the entire system since, eventually, there will be a longest chain again. Odds are exponentially decreasing for a "two equally long longest chains" to survive in the long run.
Exactly.

Quote
What does the individual node or the block explorer consider the longest chain ? GENESIS-A-B-C or GENESIS-A-X-Y ?
In practice, whichever chain it saw first. In theory, it doesn't matter.

Quote
But there might be one interesting aspect here. I think, for quick chain stabilization, it is important that the nodes pick the same chain as the correct chain. Assume, 1/2 of the nodes pick GENESIS-A-B-C and the other 1/2 of the nodes pick GENESIS-A-X-Y. In this case the "battle" for the right correct chain might take much longer. Now assume that all nodes pick GENESIS-A-B-C. In this case the "battle" will be over quite quickly (not necessarily in favour of GENESIS-A-B-C though, but the chances of oscillating back and forth should be smaller).
The chain will already stabilize quickly because it will take, on average, several minutes to extend either chain. If you were designing a protocol that tried to add blocks more often, maybe it would be worth the cost of extra reorganizations.
legendary
Activity: 1428
Merit: 1093
Core Armory Developer
July 09, 2011, 08:23:46 PM
#3
Nodes process which ever "longest chain" they hear about first.  If two nodes on opposite sides of the world solve the next block at exactly the same time, then half the world will get word of one block and start working on it, while the other half the world gets word of the other block first and starts working on that.  Once either of those chains is extended, the solution is broadcast and all nodes will switch to it, seeing that that chain is the longest.  Sure, both halves of the world could solve the next block at exactly the same time and both will be temporarily extended again.  But statistically speaking, eventually one chain will "lose", and it's entirely up to luck which one that is.

More often than not, you would get 90% of the world that sees one block, and 10% of that gets the other block first.  Unless the 10% side gets extremely lucky, the 90% will be the one to become the real chain.  The orphaned block becomes "invalid."  I believe nodes that who were working on that branch, will see what transactions need to be re-included in the new branch, but I'm not sure how that part works exactly.





newbie
Activity: 33
Merit: 0
July 09, 2011, 06:15:20 PM
#2
I sincerely hope that the amount of transactions in the block is a factor in defining the longest chain, but I don't know.
full member
Activity: 195
Merit: 100
July 09, 2011, 06:09:14 PM
#1
Trying to work my way through the code  Smiley according to Richard Feynman's principle of learning "What I can't produce - I do not understand".   Wink

So, I reached another place I do not understand.  Shocked

Every node always considers the longest chain the correct one. Yes?

Ok. What happens if there are two longest chains.

Well, this is not a problem for the future of the entire system since, eventually, there will be a longest chain again. Odds are exponentially decreasing for a "two equally long longest chains" to survive in the long run.

That said: A single node (and, similarly, blockexplorer) has at any given moment in time a concept of what is the longest chain (even if there are two equally long chains). I checked the code. In the -printblock functionality there is no clear answer to this and I did not yet manage to digest the chain reorganization algorithms to understand this aspect.

So, assume there is this situation:

               B-C
              /
GENESIS-A
              \
               X-Y

What does the individual node or the block explorer consider the longest chain ? GENESIS-A-B-C or GENESIS-A-X-Y ?

This question might be considered academic, since in the long run one of the chains will stabilize and become the longest.

But there might be one interesting aspect here. I think, for quick chain stabilization, it is important that the nodes pick the same chain as the correct chain. Assume, 1/2 of the nodes pick GENESIS-A-B-C and the other 1/2 of the nodes pick GENESIS-A-X-Y. In this case the "battle" for the right correct chain might take much longer. Now assume that all nodes pick GENESIS-A-B-C. In this case the "battle" will be over quite quickly (not necessarily in favour of GENESIS-A-B-C though, but the chances of oscillating back and forth should be smaller).

Any ideas on this?




Pages:
Jump to: