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.