Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: zef on May 26, 2011, 02:20:10 AM



Title: handling block branches
Post by: zef on May 26, 2011, 02:20:10 AM
I was having a discussion with a friend about bitcoins and he brought up a question I wasnt sure how to answer.  I've looked at the wiki, but i think i need someone to explain it in plain english to me: https://en.bitcoin.it/wiki/Protocol_rules

I want to know what happens in this scenario:
Lets assume mexico and usa use bitcoins on the same big network, but theres a single connection connecting mexico to usa.  This connection gets severed for some amount of time, say a day.  During this time both countries go on doing transactions and archiving blocks.  Lets say that usa finds blocks now at 4 per hour, while mexico only finds them at 2 per hour. So usa will have a block chain that is 48 blocks longer than mexico by the time the connection comes back. 

The question is, what happens to all the transactions in both countries when the connection is restored? My answer was that once connection was restored, mexico would download usa block chain, and because its more difficult, it would essentially wipe out all the transactions mexico made during the disconnect. This was based on my understanding of how clients accept new blockchains, but obviously this would be a huge problem for bitcoins if it was the case.  Could someone explain it to me? 


Title: Re: handling block branches
Post by: theymos on May 26, 2011, 02:57:10 AM
All of the miners in Mexico will put the transactions in their old chain back into the transaction queue once they switch chains.


Title: Re: handling block branches
Post by: zef on May 26, 2011, 12:06:53 PM
All of the miners in Mexico will put the transactions in their old chain back into the transaction queue once they switch chains.

So you are saying the blocks mexico mined will be undone, but the transactions will still exist and need to be added and verified by usa blockchain?


Title: Re: handling block branches
Post by: theymos on May 26, 2011, 01:15:16 PM
So you are saying the blocks mexico mined will be undone, but the transactions will still exist and need to be added and verified by usa blockchain?

Yes.

Transactions will only become invalid if:
- The split lasts so long that Mexico generates 100 blocks and generations therefore mature; or,
- Someone who can communicate on both sides of the split double-spends his coins.


Title: Re: handling block branches
Post by: zef on May 26, 2011, 02:11:17 PM
Interesting... So what happens to the money earned from solving the blocks on mexico's side, those transactions can't be allowed to exist if the blocks are undone, right?

This 100 block maturity level, what is that based on?  Also do you think the way bitcoin handles disconnected networks could be a problem for global acceptance of bitcoins?  If a whole country was to accept it as a national currency, would make sense to have its own version of bitcoin separate from other nations?


Title: Re: handling block branches
Post by: compro01 on May 26, 2011, 04:47:55 PM
Interesting... So what happens to the money earned from solving the blocks on mexico's side, those transactions can't be allowed to exist if the blocks are undone, right?

This 100 block maturity level, what is that based on?  Also do you think the way bitcoin handles disconnected networks could be a problem for global acceptance of bitcoins?  If a whole country was to accept it as a national currency, would make sense to have its own version of bitcoin separate from other nations?

1. they go poof and vanish as if they never existed, which they really didn't.

2. AFAIK, the number of blocks to maturity is arbitrary.

3. i wouldn't think so.

4. i personally don't think it would make sense.  you'd effectively end up with multiple independent and parallel block chains and thus multiple independent currencies, much like today, and you'd need to exchange between them to get anything done internationally, much like with current currencies, though i'm sure someone somewhere would think that makes sense.


Title: Re: handling block branches
Post by: Mike Hearn on May 26, 2011, 04:49:19 PM
Total disconnection for days on end is very rare. I think Egypt is the only recent example.


Title: Re: handling block branches
Post by: Dobrodav on May 26, 2011, 07:03:33 PM
Total disconnection for days on end is very rare. I think Egypt is the only recent example.
Should read like :
"Total disconnection for days on end is very rare. But we already saw that in Egipt.
Fact, that Egypt gov. was turn of any internete providing was good in terms of bitcoin. No transactions, no generation."


Title: Re: handling block branches
Post by: zef on May 26, 2011, 07:35:22 PM

1. they go poof and vanish as if they never existed, which they really didn't.


This means any transactions based on coins generated from blocks would disappear, this could be a big problem if actual goods were traded with that money.

Total disconnection for days on end is very rare. I think Egypt is the only recent example.

It would only take 17 hours at 6 blocks an hour to hit the 100 block level.  I mean its not very probable that something like that could happen, but it's possible.

As a lay person this would be very disconcerting, particularly if bitcoins had aspirations to be truly global.  Even if a small town or city was disconnected from the rest of the world for an extended period of time, transactions would not be safe until connection was restored.


Title: Re: handling block branches
Post by: grue on May 26, 2011, 09:25:07 PM
if there was a network split, then bitcoin users would likely find out about it, and hold off on transactions/mining until it's repaired.


Title: Re: handling block branches
Post by: Gavin Andresen on May 26, 2011, 09:31:57 PM
It would only take 17 hours at 6 blocks an hour to hit the 100 block level.  I mean its not very probable that something like that could happen, but it's possible.

If the network was split 50/50, then each half would generate blocks half as fast.  So it would take 34 hours.

For an "Egypt splits off from the rest of the network" scenario, it would probably split something like "less than 5% generated in Egypt, 95% rest of the world" in which case it would take 17/.05 = over two weeks for the blocks generated in Egypt to mature.


Title: Re: handling block branches
Post by: Frozenlock on May 26, 2011, 11:22:15 PM
Wait, what happens when the 100 blocks is reached? The network is split for good?


Title: Re: handling block branches
Post by: kjj on May 26, 2011, 11:28:02 PM
It would only take 17 hours at 6 blocks an hour to hit the 100 block level.  I mean its not very probable that something like that could happen, but it's possible.

If the network was split 50/50, then each half would generate blocks half as fast.  So it would take 34 hours.

For an "Egypt splits off from the rest of the network" scenario, it would probably split something like "less than 5% generated in Egypt, 95% rest of the world" in which case it would take 17/.05 = over two weeks for the blocks generated in Egypt to mature.

No place with enough computing power to run 100 blocks in a reasonable time at then-current difficulty will ever be disconnected.


Title: Re: handling block branches
Post by: Quantumplation on May 27, 2011, 12:10:27 AM
All of the miners in Mexico will put the transactions in their old chain back into the transaction queue once they switch chains.

Almost, but one minor caveat: The group with more people/miners would be accepted as the proper block chain.  If mexico had more users in their network than the US (given the relative sizes of the countries, I doubt it) then it would be the US transactions that would need to be re-validated.


Title: Re: handling block branches
Post by: theymos on May 27, 2011, 02:14:52 AM
Wait, what happens when the 100 blocks is reached? The network is split for good?

Coins created through generation are not spendable until they have 100 confirmations. So once a split lasts longer than 100 blocks (from the perspective of the smaller side), lots of people are likely to lose transactions, as all transactions based on the now-invalid generated coins will also become invalid.

Almost, but one minor caveat: The group with more people/miners would be accepted as the proper block chain.  If mexico had more users in their network than the US (given the relative sizes of the countries, I doubt it) then it would be the US transactions that would need to be re-validated.

The OP specified that Mexico is the smaller side.


Title: Re: handling block branches
Post by: zef on May 27, 2011, 02:54:28 AM
ok wow i get it, thanks for the replies.  So coin generated from block finding are not spendable until there are 100 confirmations, and a confirmation is equivalent to solving one block? 

If that is the case that is so interesting, I had no idea.  I'm glad this seems a bit more robust than i first thought. So yes you can be screwed if you are disconnected long enough, but for the most part there is a reasonable amount of time to get back into the network, related to your relative size to the network. 

Worst case(time-wise) is like a 49/51 split near the end of a difficulty phase, where if like last phase, block gen rate was over 13 per hour.  Of course this scenario is very unlikely though, it only really seems plausible if small poorly connected sections of the network disconnect, but then they would have days, if not weeks to re-join the network.