Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: ebyccc on May 19, 2016, 01:54:34 AM



Title: How could a miner know he is in the best block chain
Post by: ebyccc on May 19, 2016, 01:54:34 AM
I have finished reading the bitcoin developer guide but still confused. Like you are a head first miner, and received a block inventory (broadcasted by its inventor), then you would reply a getheader to the peer, and he would response a sequence of headers. What if you find that sequence cannot match your own block chain, and judge whether the peer  or yourself is wrong (by which i mean not on the longest chain)?


Title: Re: How could a miner know he is in the best block chain
Post by: jambola2 on May 19, 2016, 12:44:28 PM
Let the letters represent hashes.

Other persons chain: [a b c d e f g h i j k]
Your chain: [a b c d e f l m n o p]

You send a getheader with your chain:
Response: [g h i j k]
Does not match [l m n o p]

Compare total difficulty of [g h i j k] and [l m n o p]. Stay with whichever chain has a higher total difficulty.



Title: Re: How could a miner know he is in the best block chain
Post by: wintermeasures on May 19, 2016, 04:49:01 PM
Let the letters represent hashes.

Other persons chain: [a b c d e f g h i j k]
Your chain: [a b c d e f l m n o p]

You send a getheader with your chain:
Response: [g h i j k]
Does not match [l m n o p]

Compare total difficulty of [g h i j k] and [l m n o p]. Stay with whichever chain has a higher total difficulty.



sorry friend, can u explain to us with more simple word? i cant understand u mean, sorry im newbie here  ??? ??? ???
thank you.


Title: Re: How could a miner know he is in the best block chain
Post by: RealBitcoin on May 19, 2016, 04:50:46 PM
Let the letters represent hashes.

Other persons chain: [a b c d e f g h i j k]
Your chain: [a b c d e f l m n o p]

You send a getheader with your chain:
Response: [g h i j k]
Does not match [l m n o p]

Compare total difficulty of [g h i j k] and [l m n o p]. Stay with whichever chain has a higher total difficulty.



Plus its also the longest chain right? I remember there was a new fix where the longest chain with the highest difficulty is selected as the original.


Title: Re: How could a miner know he is in the best block chain
Post by: jacobmayes94 on May 19, 2016, 04:56:05 PM
I thought bitcoind already did that by default.

Jacob


Title: Re: How could a miner know he is in the best block chain
Post by: jambola2 on May 19, 2016, 07:38:23 PM
sorry friend, can u explain to us with more simple word? i cant understand u mean, sorry im newbie here  ??? ??? ???
thank you.

The original poster asked for a somewhat complicated answer itself. In short, what I basically said was that in order to check which chain is the best, the getheaders function can be used. You give another user your blockchain, and they tell you which blocks they think you are missing. You compare their blocks to your blocks, and then find out which has a higher sum of difficulty.

Plus its also the longest chain right? I remember there was a new fix where the longest chain with the highest difficulty is selected as the original.

No, longest chain is only a way to explain it in a simple manner. Highest total difficulty is what is used.
A chain with blocks [A,B,C,D,E] is longer than chain [A,B,P,Q,R,S] if the difficulty of C+D+E > difficulty of P+Q+R+S even though there are more blocks in the latter.

There are potential attacks on the blockchain wherein an attacker can create a chain where difficulty would be lower than actual chain difficulty, allowing them to create blocks faster. In order to prevent this attack, the 'longer' chain is decided by sum of difficulty and not total length.

A chain with a million blocks of difficulty 1 is shorter than a chain with two blocks with a difficulty of 600,000


Title: Re: How could a miner know he is in the best block chain
Post by: RealBitcoin on May 19, 2016, 08:54:56 PM

No, longest chain is only a way to explain it in a simple manner. Highest total difficulty is what is used.
A chain with blocks [A,B,C,D,E] is longer than chain [A,B,P,Q,R,S] if the difficulty of C+D+E > difficulty of P+Q+R+S even though there are more blocks in the latter.

There are potential attacks on the blockchain wherein an attacker can create a chain where difficulty would be lower than actual chain difficulty, allowing them to create blocks faster. In order to prevent this attack, the 'longer' chain is decided by sum of difficulty and not total length.

A chain with a million blocks of difficulty 1 is shorter than a chain with two blocks with a difficulty of 600,000

And can't that be faked? For example by introducing fake blocks with fake difficulty settings.

How does the miners know that the blocks they get are authentic?


Title: Re: How could a miner know he is in the best block chain
Post by: Cuidler on May 19, 2016, 09:20:06 PM
No, longest chain is only a way to explain it in a simple manner. Highest total difficulty is what is used.
A chain with blocks [A,B,C,D,E] is longer than chain [A,B,P,Q,R,S] if the difficulty of C+D+E > difficulty of P+Q+R+S even though there are more blocks in the latter.

There are potential attacks on the blockchain wherein an attacker can create a chain where difficulty would be lower than actual chain difficulty, allowing them to create blocks faster. In order to prevent this attack, the 'longer' chain is decided by sum of difficulty and not total length.

A chain with a million blocks of difficulty 1 is shorter than a chain with two blocks with a difficulty of 600,000


Interesting, I though time stamp in block solves this, as million blocks of difficulty 1 could not be created as there is not enought time to create million blocks, all ten minutes apart. What is the attack vector if just longest chain is selected as best, I mean how you fool the time stamps to have today million valid blocks of difficulty 1 when clearly not enought time for million blocks since late 2009 all ten minutes apart...


Title: Re: How could a miner know he is in the best block chain
Post by: jambola2 on May 22, 2016, 08:20:38 AM

No, longest chain is only a way to explain it in a simple manner. Highest total difficulty is what is used.
A chain with blocks [A,B,C,D,E] is longer than chain [A,B,P,Q,R,S] if the difficulty of C+D+E > difficulty of P+Q+R+S even though there are more blocks in the latter.

There are potential attacks on the blockchain wherein an attacker can create a chain where difficulty would be lower than actual chain difficulty, allowing them to create blocks faster. In order to prevent this attack, the 'longer' chain is decided by sum of difficulty and not total length.

A chain with a million blocks of difficulty 1 is shorter than a chain with two blocks with a difficulty of 600,000

And can't that be faked? For example by introducing fake blocks with fake difficulty settings.

How does the miners know that the blocks they get are authentic?

Alright, let me explain difficulty.

Mining involves finding hashes that match the parameters. The difficulty specifies that the final hash is invalid unless the value of your hash is lower than a certain value.

For example, this is difficulty 1: 0x00000000FFFF
And this is around difficulty 16,000: 0x00000000000404CB

A hash value 0x00000000A123..........  would be valid for difficulty 1 and not valid for difficulty 16,000.

So, I could manufacture blocks at a lower difficulty, but it would make my chain shorter, and i could manufacture blocks at a higher difficulty but it would proportionally increase time spent making each block.


Title: Re: How could a miner know he is in the best block chain
Post by: jambola2 on May 22, 2016, 08:26:08 AM
No, longest chain is only a way to explain it in a simple manner. Highest total difficulty is what is used.
A chain with blocks [A,B,C,D,E] is longer than chain [A,B,P,Q,R,S] if the difficulty of C+D+E > difficulty of P+Q+R+S even though there are more blocks in the latter.

There are potential attacks on the blockchain wherein an attacker can create a chain where difficulty would be lower than actual chain difficulty, allowing them to create blocks faster. In order to prevent this attack, the 'longer' chain is decided by sum of difficulty and not total length.

A chain with a million blocks of difficulty 1 is shorter than a chain with two blocks with a difficulty of 600,000


Interesting, I though time stamp in block solves this, as million blocks of difficulty 1 could not be created as there is not enought time to create million blocks, all ten minutes apart. What is the attack vector if just longest chain is selected as best, I mean how you fool the time stamps to have today million valid blocks of difficulty 1 when clearly not enought time for million blocks since late 2009 all ten minutes apart...

Bitcoin does not limit you to 1 block every 10 minutes though. Check out blockchain.info's list of recent blocks, and I'm sure you'll see some blocks under 5 minutes apart.



Title: Re: How could a miner know he is in the best block chain
Post by: Bitcoinpro on May 22, 2016, 10:56:48 AM
if ur using the latest client u should be on the right fork but i guessing u want to check to make sure


Title: Re: How could a miner know he is in the best block chain
Post by: RealBitcoin on May 22, 2016, 02:00:34 PM
Alright, let me explain difficulty.

Mining involves finding hashes that match the parameters. The difficulty specifies that the final hash is invalid unless the value of your hash is lower than a certain value.

For example, this is difficulty 1: 0x00000000FFFF
And this is around difficulty 16,000: 0x00000000000404CB

A hash value 0x00000000A123..........  would be valid for difficulty 1 and not valid for difficulty 16,000.

So, I could manufacture blocks at a lower difficulty, but it would make my chain shorter, and i could manufacture blocks at a higher difficulty but it would proportionally increase time spent making each block.

Ok i kinda get it now, everything is cryptographically guaranteed, not just a parameter in a database.

No wonder its called cryptocurrency. It is really fascinating how bitcoin works behind the scenes, these crypto operations surely was designed by geniuses.