0
I'm a software developer, and I've been trying to figure out how a node decides whether a block is valid, I do understand the hashes in bitcoin, the merkle root, and all those aspects but my question is:
If someone edits a block, how does the network know that "X" node modified a block? are the nodes constantly in communication sending some sort of fingerprint that changes if information gets modified (or sending the whole blockchain)?
If a node (A) detects that Block #XHeight from Node (b) is not valid, how does the network know who is right and who is not, since The block is valid for Node B but not for node A, how do they solve such argument? does the network goes into an election process, and the network decides which hash is the valid one? : how does two nodes certify that one of them is actually the valid one? is there some sort of "democracy" system where nodes vote in favor or against one specific hash in order to decide who's right between node A and Node B?
I'd like to get technical answers, since I'm trying to understand blockchain and bitcoin at a code level.
But let’s say I modify a block, how does the network know that I actually modified a block, that I have a invalid chain? Are the nodes constanly communicating with each other? If they are, what are they sending in order to let the network know about these modifications? – Juan – 2019-02-10T22:53:16.750
1The only person you can deceive by attempting to modify a block is yourself. If your try to broadcast a modified block, then any other node on the network will reject the block, either because its hash does not match the expected hash of the block which is expected at that height, or because they have a longer valid chain which does not include that block. – Mark H – 2019-02-10T22:55:39.947
Nodes do constantly communicate with each other when new blocks are created or new transactions are created. These are all broadcast, and you typically receive information from multiple different sources, and your own node determines which information is correct based on which one it validates to be the longest chain. – Mark H – 2019-02-10T22:57:56.307
So If I broadcast my invalid block, and the network detects this, then the network would send me back the valid block. Right? – Juan – 2019-02-10T23:01:20.670
1Other nodes will detect an invalid block and discard it, but it is not required that they inform you of the valid one. Your node will need to send a
getheadersorgetblockscommand to its peers to request the most recent information, and the peers will respond with the newest blocks they know about. You can validate all of this information and determine its correctness. During normal operation, nodes will automatically send you information about new blocks with aninvcommand, without you requesting it (unless you opt out of this information in the initialversionmessage to the peer). – Mark H – 2019-02-10T23:08:27.657Okay. Finally I understand such things. Thank you! I just have one more question, You mention that every node determines which information is correct, meaning, each node computes which block might be valid and which one might be not. Let’s put this example (not based on Bitcoin’s blockchain): we have 2 nodes trying to decide whether Block Z is valid. Node A says that it’s valid, Node B says that is not valid (Node A modified it). How does the network solve this? Does it go into an election process or a consensus system for blocks? I think this is called the byzantine fault problem. – Juan – 2019-02-10T23:26:28.567
If A modified the block, B will simply reject it. Instead, B will receive the valid block from a different peer, and will most likely blacklist A. Bitcoin relies on receiving information from multiple peers, because you can't rely on a single source of information being up-to-date. By default, Bitcoin Core will connect outward to 8 peers, but will receive as many as 125 incoming peers. The chances of not getting correct information from at least one peer is very low. You only need 1 honest peer, even if the others are malicious. If all peers are malicious, it is called an eclipse attack. – Mark H – 2019-02-11T00:18:51.697
Thank you so much! I’d like to continue with this conversation since my questions are based on private blockchains’ concept. But so far Thank you, I might open another question.. greetings – Juan – 2019-02-11T00:39:21.843