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