What happens if a miner (accidentally or maliciously) publishes a block with correct proof of works, which contains an invalid transaction (e.g., a double spending one)? Is the block ignored by the network?
1 Answer
A block with an invalid transaction is an invalid block, regardless of the proof of work.
When it is broadcast, other full nodes will ignore it as spam, and typically disconnect from the node that sent it. A bad block is unlikely to propagate very far on the network.
When other miners see it, they will also ignore it. If they mine on top of it, they will be wasting their hashing power. This also means that the miner who did the proof of work on the invalid block has wasted their own hashing power. This is why it's important that miners validate the transactions they include in blocks.
-
if a block with any invalid transaction will be considered as an invalid block, can we say that whenever a peer commits a block into the ledger, this block is guaranteed to be a valid block?– Qi ZhangCommented Jul 13, 2018 at 3:42
-
1I would agree that's a correct a statement, just so long as you understand that "the ledger" is an agreed upon version. There can be ledgers that barely anyone agrees are the correct one. It's probably more accurate to say that any block that miners are mining on top of is considered valid by those miners.– JestinCommented Jul 13, 2018 at 15:25