Bitcoin Forum
January 18, 2019, 07:05:14 PM *
News: Latest Bitcoin Core release: 0.17.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What happenes when a fork is resolved?  (Read 596 times)
bolfio
Newbie
*
Offline Offline

Activity: 13
Merit: 1


View Profile
October 13, 2017, 06:04:39 PM
 #1

Hi. I am "new" in bitcoin, I read several books about it and I try to understand how it works.

Well, I understand the sense of mining: building new blocks with transactions to be confirmed. And the one who mines it gets new bitcoins via the coinbase transfer. I also understand that it can happen that 2 or more new blocks are mined simultaneously - so at the end, the longest chain will "win" and the other blocks will end in a fork.

Well, I am still confused about the following thing: I read that the transactions in the outpaced blocks go back in the mempool, waiting to come to another block (and this opens the possibility for a double-spending attack). But my questions are:

- Let's assume there were to blocks mined simultaneously. Did both get new bitcoins? What happenes with the one who will "lose the race" for the longest chain? Are his new bitcoins cancelled? And if, what if he already spent it?

- And: If there is a fork: Everyone who has a transaction in it would be able to do a double spending attack?

- Assumed that one makes a double-spend attack (waiting for more than several blocks, theoretically). I always read that the vendor then will "lose" his bitcoins (clear), since the transaction will get invalid. But: Theoretically, the vendor who gets attacked may already spent the amount he got from the fauld transaction. What then? Isn't he the one who lose, but the one he payed with this bitcoins?


I hope someone can answer these questions.......
1547838314
Hero Member
*
Offline Offline

Posts: 1547838314

View Profile Personal Message (Offline)

Ignore
1547838314
Reply with quote  #2

1547838314
Report to moderator
1547838314
Hero Member
*
Offline Offline

Posts: 1547838314

View Profile Personal Message (Offline)

Ignore
1547838314
Reply with quote  #2

1547838314
Report to moderator
1547838314
Hero Member
*
Offline Offline

Posts: 1547838314

View Profile Personal Message (Offline)

Ignore
1547838314
Reply with quote  #2

1547838314
Report to moderator
"I'm sure that in 20 years there will either be very large transaction volume or no volume." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1547838314
Hero Member
*
Offline Offline

Posts: 1547838314

View Profile Personal Message (Offline)

Ignore
1547838314
Reply with quote  #2

1547838314
Report to moderator
1547838314
Hero Member
*
Offline Offline

Posts: 1547838314

View Profile Personal Message (Offline)

Ignore
1547838314
Reply with quote  #2

1547838314
Report to moderator
DannyHamilton
Legendary
*
Offline Offline

Activity: 2198
Merit: 1390



View Profile
October 13, 2017, 07:59:18 PM
 #2

I read that the transactions in the outpaced blocks go back in the mempool, waiting to come to another block

This is effectively only true for the transactions that are not already in block in the other chain.

- Let's assume there were to blocks mined simultaneously. Did both get new bitcoins?

The entire network will be split.  Nodes, merchants, and users that accept one of the blocks will see that the miner of THAT block got new bitcoins and that the miner of the other block did not. Nodes, merchants, and users that accept the other blocks will see the opposite. The network will remain in this split state until one of the chains establishes "longer chain", and at that time the "shorter chain" will become orphaned.

What happenes with the one who will "lose the race" for the longest chain? Are his new bitcoins cancelled?

As far as the entire bitcoin system is concerned, his bitcoins never existed.  All history associated with that chain is ignored as if it never happened.

And if, what if he already spent it?

The consensus rules do not allow a coinbase output to be spent until it has 101 confirmations (100 more blocks after that block is created).  This means that the fork would need to continue to exist for nearly 17 hours without either side becoming "longer".  This is extremely unlikely, however if it did happen and if the miner did spend the bitcoins after that 101st block, then the transaction would disappear along with the miner's reward.  If you find that the network is split for more than a block or two, and you aren't 100% certain that you are on the chain that will become the longer chain, then YOU SHOULD NOT ACCEPT ANY TRANSACTION AS COMPLETED UNTIL THE SPLIT RESOLVES.

- And: If there is a fork: Everyone who has a transaction in it would be able to do a double spending attack?

Most of the transactions in one side of the split will also ALREADY be confirmed in the other side of the split as well.  However, this is the reason that many services require 3 or 6 confirmations before accepting a transaction as completed.  It is extremely unlikely for a split to last than many blocks without being resolved.

- Assumed that one makes a double-spend attack (waiting for more than several blocks, theoretically). I always read that the vendor then will "lose" his bitcoins (clear), since the transaction will get invalid. But: Theoretically, the vendor who gets attacked may already spent the amount he got from the fauld transaction. What then? Isn't he the one who lose, but the one he payed with this bitcoins?

Correct.  If any transaction becomes invalid, then all the transactions that are built off of that transaction are also invalid.

I hope someone can answer these questions.......

I tried.

I hope I was clear.

bolfio
Newbie
*
Offline Offline

Activity: 13
Merit: 1


View Profile
October 13, 2017, 10:31:40 PM
 #3

Wow, thank you very much, now anything makes sense to me! It wasn't clear to me that in both chains the transactions could be confirm - even it is clear. Your explanation makes more sense that the ones in EVERY book I read so far.

Theres only one question left. You wrote:

Quote
The entire network will be split.  Nodes, merchants, and users that accept one of the blocks will see that the miner of THAT block got new bitcoins and that the miner of the other block did not. Nodes, merchants, and users that accept the other blocks will see the opposite. The network will remain in this split state until one of the chains establishes "longer chain", and at that time the "shorter chain" will become orphaned.

Ok, I understand this. I understand this point of view what users see. But what sees the miner? I realize that the shorter chain will become orphaned. But what happenes to the "new" coins of these succesful miners who are in the shorter chain? I hope you know what I mean.

I mean: After the shorter chain will become orphaned, EVERY user will see the longer chain. Then there is a real consensus. And this means that only the ones in the longer chain should have new coins.
bolfio
Newbie
*
Offline Offline

Activity: 13
Merit: 1


View Profile
October 14, 2017, 12:03:58 AM
 #4

Oh, just another question. You wrote:

Quote
The entire network will be split.  Nodes, merchants, and users that accept one of the blocks will see that the miner of THAT block got new bitcoins and that the miner of the other block did not. Nodes, merchants, and users that accept the other blocks will see the opposite. The network will remain in this split state until one of the chains establishes "longer chain", and at that time the "shorter chain" will become orphaned.

In these case, are there is still one common pool of transactions? Let's assume I make a transfer and I am following chain 1. But the transfer is confirmed in a block of chain 2 first. What do I see then? I guess it is not possible that my transfer is in chain one confirmed and about 20 minutes later also in chain two, since it is already confirmed once.....
ranochigo
Legendary
*
Offline Offline

Activity: 1624
Merit: 1124

Somewhat inactive.


View Profile WWW
October 14, 2017, 04:44:27 AM
 #5

Ok, I understand this. I understand this point of view what users see. But what sees the miner? I realize that the shorter chain will become orphaned. But what happenes to the "new" coins of these succesful miners who are in the shorter chain? I hope you know what I mean.

I mean: After the shorter chain will become orphaned, EVERY user will see the longer chain. Then there is a real consensus. And this means that only the ones in the longer chain should have new coins.
The coinbase transaction on that orphaned chain would be as if it has never existed. It's usually just for a block or two so it isn't a huge loss to them; unless they somehow create a longer fork due to differing rules.
In these case, are there is still one common pool of transactions?
Strictly speaking, the mempool differs for every single node across the network. Given that the mempool of every node of the network is consistent before the split, they would have the same pool of transaction at the point of split (confirmed+unconfirmed).
Let's assume I make a transfer and I am following chain 1. But the transfer is confirmed in a block of chain 2 first. What do I see then? I guess it is not possible that my transfer is in chain one confirmed and about 20 minutes later also in chain two, since it is already confirmed once.....
Which chain are you on? Lets say there's two blockchain, chain A and chain B. If you are on chain A and it has one confirmation, you would see one confirmation in your client. If you are on the chain B where your transaction has never been included in a block, you wouldn't see a confirmation. When the chain B gets longer than the chain A, chain A would get orphaned and your transaction would have zero confirmation again.  This is one of the reason why people require more than one confirmation for the maximum security that they can have.

bolfio
Newbie
*
Offline Offline

Activity: 13
Merit: 1


View Profile
October 14, 2017, 02:32:59 PM
 #6

Ok, I understand this. I understand this point of view what users see. But what sees the miner? I realize that the shorter chain will become orphaned. But what happenes to the "new" coins of these succesful miners who are in the shorter chain? I hope you know what I mean.

I mean: After the shorter chain will become orphaned, EVERY user will see the longer chain. Then there is a real consensus. And this means that only the ones in the longer chain should have new coins.
The coinbase transaction on that orphaned chain would be as if it has never existed. It's usually just for a block or two so it isn't a huge loss to them; unless they somehow create a longer fork due to differing rules.
In these case, are there is still one common pool of transactions?
Strictly speaking, the mempool differs for every single node across the network. Given that the mempool of every node of the network is consistent before the split, they would have the same pool of transaction at the point of split (confirmed+unconfirmed).
Let's assume I make a transfer and I am following chain 1. But the transfer is confirmed in a block of chain 2 first. What do I see then? I guess it is not possible that my transfer is in chain one confirmed and about 20 minutes later also in chain two, since it is already confirmed once.....
Which chain are you on? Lets say there's two blockchain, chain A and chain B. If you are on chain A and it has one confirmation, you would see one confirmation in your client. If you are on the chain B where your transaction has never been included in a block, you wouldn't see a confirmation. When the chain B gets longer than the chain A, chain A would get orphaned and your transaction would have zero confirmation again.  This is one of the reason why people require more than one confirmation for the maximum security that they can have.

Ah, fantastic, now I understand this parts. Thanks. I didn't find a description of these cases in any book... Thanks!  But der is still one question:


Ok, I understand this. I understand this point of view what users see. But what sees the miner? I realize that the shorter chain will become orphaned. But what happenes to the "new" coins of these succesful miners who are in the shorter chain? I hope you know what I mean.

I mean: After the shorter chain will become orphaned, EVERY user will see the longer chain. Then there is a real consensus. And this means that only the ones in the longer chain should have new coins.
The coinbase transaction on that orphaned chain would be as if it has never existed. It's usually just for a block or two so it isn't a huge loss to them; unless they somehow create a longer fork due to differing rules.

I understand that they would be seen as never existed. But my question is: When a new block is mined, when gets the miner the new coins into his wallet? Immediately? Or must he wait for this 100 confirmations which DannyHamilton mentioned?

I mean: Assumed that two miners make a block at the same time and the wallet would get the new coins immediately, one would lose them after resolving the fork. I hope you know what I mean, but i wasn't able to find an answer to this.
bolfio
Newbie
*
Offline Offline

Activity: 13
Merit: 1


View Profile
October 14, 2017, 02:40:25 PM
 #7


Most of the transactions in one side of the split will also ALREADY be confirmed in the other side of the split as well.  However, this is the reason that many services require 3 or 6 confirmations before accepting a transaction as completed.  It is extremely unlikely for a split to last than many blocks without being resolved.


So the 6 confirmations is an experience value? or is there a boundary value of probability one could show mathematically?
DannyHamilton
Legendary
*
Offline Offline

Activity: 2198
Merit: 1390



View Profile
October 14, 2017, 03:49:04 PM
 #8


Most of the transactions in one side of the split will also ALREADY be confirmed in the other side of the split as well.  However, this is the reason that many services require 3 or 6 confirmations before accepting a transaction as completed.  It is extremely unlikely for a split to last than many blocks without being resolved.


So the 6 confirmations is an experience value? or is there a boundary value of probability one could show mathematically?

According to Mani Rosenfeld:
If the average time to find a block is T, and the typical time for a found block to propagate in the network is t, then the proportion of orphans among all blocks will be roughly 1/(1+T/t).

In the case of Bitcoin, the average time to find a block tends to be somewhere around 10 minutes.  A conservative estimate for the typical time to propagate in the network would be less than 5 seconds.  Converting 10 minutes to 600 seconds and plugging those values in to the equation...

1/(1+600/5) is approximately 0.00826 = 0.826%

So:
  • The chances that the next block solved will be orphaned is probably less than 0.826%.
  • The chances that the next two blocks in a row will be orphaned is probably less than  0.008262 = 0.0000682 = 0.00682%
  • The chances that the next three blocks in a row will be orphaned is probably less than  0.008263 = 0.000000564 = 0.0000564%
  • The chances that the next four blocks in a row will be orphaned is probably less than  0.008264 = 0.00000000466 = 0.000000466%
  • The chances that the next five blocks in a row will be orphaned is probably less than  0.008265 = 0.0000000000385 = 0.00000000385%
  • The chances that the next six blocks in a row will be orphaned is probably less than  0.008266 = 0.000000000000318 - 0.0000000000318%

If you don't like my estimates of 600 seconds and 5 seconds, then plug in your own estimate and see how it works out.

bolfio
Newbie
*
Offline Offline

Activity: 13
Merit: 1


View Profile
October 14, 2017, 11:09:55 PM
 #9


Most of the transactions in one side of the split will also ALREADY be confirmed in the other side of the split as well.  However, this is the reason that many services require 3 or 6 confirmations before accepting a transaction as completed.  It is extremely unlikely for a split to last than many blocks without being resolved.


So the 6 confirmations is an experience value? or is there a boundary value of probability one could show mathematically?

According to Mani Rosenfeld:
If the average time to find a block is T, and the typical time for a found block to propagate in the network is t, then the proportion of orphans among all blocks will be roughly 1/(1+T/t).

In the case of Bitcoin, the average time to find a block tends to be somewhere around 10 minutes.  A conservative estimate for the typical time to propagate in the network would be less than 5 seconds.  Converting 10 minutes to 600 seconds and plugging those values in to the equation...

1/(1+600/5) is approximately 0.00826 = 0.826%

So:
  • The chances that the next block solved will be orphaned is probably less than 0.826%.
  • The chances that the next two blocks in a row will be orphaned is probably less than  0.008262 = 0.0000682 = 0.00682%
  • The chances that the next three blocks in a row will be orphaned is probably less than  0.008263 = 0.000000564 = 0.0000564%
  • The chances that the next four blocks in a row will be orphaned is probably less than  0.008264 = 0.00000000466 = 0.000000466%
  • The chances that the next five blocks in a row will be orphaned is probably less than  0.008265 = 0.0000000000385 = 0.00000000385%
  • The chances that the next six blocks in a row will be orphaned is probably less than  0.008266 = 0.000000000000318 - 0.0000000000318%

If you don't like my estimates of 600 seconds and 5 seconds, then plug in your own estimate and see how it works out.


Thank you!
bolfio
Newbie
*
Offline Offline

Activity: 13
Merit: 1


View Profile
October 14, 2017, 11:18:26 PM
 #10



I understand that they would be seen as never existed. But my question is: When a new block is mined, when gets the miner the new coins into his wallet? Immediately? Or must he wait for this 100 confirmations which DannyHamilton mentioned?

I mean: Assumed that two miners make a block at the same time and the wallet would get the new coins immediately, one would lose them after resolving the fork. I hope you know what I mean, but i wasn't able to find an answer to this.

Ah ok, the rule is like DannyHamilton said: For each input, if the referenced output transaction is coinbase (i.e. only 1 input, with hash=0, n=-1), it must have at least COINBASE_MATURITY (100) confirmations; else reject this transaction.

Now I understand. I wasn't clear to me. I thought they are just not spendable for 100 confirmations long..........  I'm idiot Wink
bolfio
Newbie
*
Offline Offline

Activity: 13
Merit: 1


View Profile
October 14, 2017, 11:26:25 PM
 #11


According to Mani Rosenfeld:
If the average time to find a block is T, and the typical time for a found block to propagate in the network is t, then the proportion of orphans among all blocks will be roughly 1/(1+T/t).



I also found this formula in one of his posts now. I hope I find a mathematical proof for this estimation. I will read his papers now.
Pages: [1]
  Print  
 
Jump to:  

Bitcointalk.org is not available or authorized for sale. Do not believe any fake listings.
Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!