Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: eugene111 on May 31, 2018, 11:46:27 AM



Title: Who network detects that block is invalid
Post by: eugene111 on May 31, 2018, 11:46:27 AM
Assuming I have 3 nodes and they are fully synced and 3 of them has 5 equal blocks:
1 node:   1 -> 2 -> 3 -> 4 -> 5
2 node:   1 -> 2 -> 3 -> 4 -> 5
3 node:   1 -> 2 -> 3 -> 4 -> 5

Imagine that a bad guy who owns node 2 changed data in block 3 (probably by using some binary editor or by re-mining of this block) so
2 node will have: 1 -> 2 -> 3c  ->  4  ->  5

and blocks 4 and 5 must became invalid, but - if nobody checks this validity nobody will know that 3c is invalid.
As I understand to proof that 3 is invalid - we need to calculate it's hash and compare with the prev hash in block 4. So the question 1. Is this validation perfomed at some time?

Then the invalid block 3c is published to the network. How is it validated that this block is invalid? Node just look up for the node with the same height and compares hashes? and if they are different - it is rejected?




Title: Re: Who network detects that block is invalid
Post by: nc50lc on May 31, 2018, 12:05:35 PM
Those were validated by all of the nodes via consensus (https://bitcoin.org/en/glossary/consensus), means "the more, the real~er".

In the end, all other nodes will invalidate that edited block because your node is the only one "voting" that block 3c is valid.
If someone try to make a transaction that uses an input from that block, it will just return with an error like "invalid missing inputs".


Title: Re: Who network detects that block is invalid
Post by: ranochigo on May 31, 2018, 12:06:42 PM
Full validation is only performed when they receive the blocks from their peers. When the client is opened, it only validates the last X blocks and its not a full validation.

In the case of Bitcoin Core nodes, they validate every single block and transaction that they receive. If any of the blocks doesn't follow the network's rule, the node will ignore the transaction. This includes blocks with low difficulty, invalid transactions etc; basically whichever blocks that does not follow the rules of the node. Since nodes does not consider invalid blocks, I can modify the blocks on my computer all I want (if I could) but no one would recognise it. Unless, the way I modify the block makes it such that it will follow their specific set of rules.

In the process of validation, nodes cannot rely on other nodes to give them the correct block hash. This would simply make it vulnerable to loads of attacks.


Title: Re: Who network detects that block is invalid
Post by: watashi-kokoto on May 31, 2018, 02:30:19 PM
Assuming I have 3 nodes and they are fully synced and 3 of them has 5 equal blocks:
1 node:   1 -> 2 -> 3 -> 4 -> 5
2 node:   1 -> 2 -> 3 -> 4 -> 5
3 node:   1 -> 2 -> 3 -> 4 -> 5

1 node:   1 -> 2 -> 3 -> 4 -> 5
2 node:   1 -> 2 -> 3 -> 4 -> 5
3 node:   1 -> 2 -> 3 -> 4 -> 5



Imagine that a bad guy who owns node 2 changed data in block 3 (probably by using some binary editor or by re-mining of this block) so
2 node will have: 1 -> 2 -> 3c  ->  4  ->  5

1 node:   1 -> 2 -> 3 -> 4 -> 5
2 node:   1 -> 2 -> 3c
3 node:   1 -> 2 -> 3 -> 4 -> 5



and blocks 4 and 5 must became invalid, but - if nobody checks this validity nobody will know that 3c is invalid.
As I understand to proof that 3 is invalid - we need to calculate it's hash and compare with the prev hash in block 4. So the question 1. Is this validation perfomed at some time?

This validation is performed when a new node (node 4) is connecting to the network and syncing:

1 node:   1 -> 2 -> 3 -> 4 -> 5
2 node:   1 -> 2 -> 3c
3 node:   1 -> 2 -> 3 -> 4 -> 5
4 node:   1 -> 2



Then the invalid block 3c is published to the network. How is it validated that this block is invalid? Node just look up for the node with the same height and compares hashes? and if they are different - it is rejected?


                  ,-> 3 -> 4 -> 5
4 node:   1 -> 2 <
                  '-> 3c


Node 4 learns that two block chains exist. Node 4 determines the total proof of work (mining power spent) of all block chains. Once it is done it selects the longest valid chain.

                  ,-> 3 -> 4 -> 5  <- Longest Proof of Work Chain
4 node:   1 -> 2 <
                  '-> 3c


Afterwards, the node 2 is only node on the network with corrupted block chain.


1 node:   1 -> 2 -> 3 -> 4 -> 5
2 node:   1 -> 2 -> 3c
3 node:   1 -> 2 -> 3 -> 4 -> 5
4 node:   1 -> 2 -> 3 -> 4 -> 5