1

I read about block structure, hashing, verifying transactions, but I am struggling to understand how a bad block is rejected by miners.

Let's say I am a bad actor and win the PoW competition and I have added a fraudulent transaction within the block (which is still valid after a state change). I broadcast my block and solution. Do other nodes actually check the transactions in the block versus their local ones? If not, how would they identify that there is a bad transaction?

And if they say it's valid, wouldn't this block be broadcast to all nodes and make it in the blockchain. Obviously, this doesn't happen but want to know the reason.

1 Answer 1

1

The blockchain's motto is to Trust but Verify. Each node follows a set of rules called consensus rules , it is a set of rules that define what kind of a block is valid in the current blockchain.

Assume that a bad actor wins the POW competition and creates an invalid block. It then broadcasts this block to all the neighbouring nodes who are still trying to solve the problem because they don't know it has been solved. Now here's where the situation diverges into two scenarios.

  1. The receiving block rejects the block : Remember that each node has a local copy of the consensus rules embedded in their node's code. So it simply rejects the bad block and continues to solve the problem ignoring the bad block.
  2. The receiving block accepts the block : To accept the block, the node's consensus rules must be different from what define a valid block. Hence, the accepting node can change it's own rules and deem the block valid and pass the block to next neighbouring nodes. If many of the nodes do the same changing of their own rules and passing on, the valid network's security degrades and a fork is formed.

Now the forks case has less chance to happen if just a single miner is a bad actor. On the incentive of getting the block reward, a good miner will reject the bad block and rush to solve the problem as they still have the chance to get rewarded.

But if the intention itself among the miners is to define/change the rules and change what block is valid ,it's a fork and the example for that is the Ethereum Classic chain.

5
  • Thank you very much for the detailed response. However, I still struggle to understand how the embedded consensus rules will reject a block. Let's say I change one of the transaction and I change the toAddress to mine. How will the consensus rules detect my fraud transaction. Somehow it needs to know that this transaction hasn't been broadcasted to other nodes and is fabricated. Jan 23 at 7:38
  • The fancy consensus rules are just some Go/C++ checks that validate a block. If the checks fail, the block is rejected. If you open up that node code and change it, that's what's called as change of consensus rules. Check below for your case
    – Pranay
    Jan 23 at 9:04
  • 1
    Every transaction contains hash of it's contents signed by a private key. So if someone changes a field, hash becomes different and the signature is not valid. So even if some miner creates new rules and deems it valid and broadcasts it, other valid miners will reject as their rules say that transaction is invalid because signature has changed.
    – Pranay
    Jan 23 at 9:07
  • 1
    Perfect. Got it, so essentially the miner cannot tamper with another person (address) transaction since it will change the hash and other nodes will reject it since the signature verification fails. That makes sense now. Thank you. Jan 23 at 9:31
  • Yes, that is correct. For more on this, refer this.
    – Pranay
    Jan 23 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.