<p>Merkle root is a part of the block header and is calculated based on the transactions included in the block. If transactions in the block are changed, it would change the merkle root in the header. If the merkle root is changed, the block header will change and the header hash which was calculated initially will no longer be valid.</p>

<blockquote>
  <p>When a node receive a block, how it verifies it (just rehashing the header, or recalculating merkle root first then rehashing the header)?</p>
</blockquote>

<p>When a full node receives a block it performs various checks to ensure the block conforms to the consensus rules. This includes checking that all the transactions in the block are valid. If any particular transaction is not valid, then the entire block will be rejected by the full node. After verification of the transactions, the full node would verify the merkle hash. Then full node will look at the block header and verify the timestamp rule, previous block hash, and other components and then calculate the block header hash and check if it is less than the target. If one of the verification rules fail, the node will reject the block. You can find a complete list of block verification rules <a href="https://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messages" rel="nofollow noreferrer">here.</a></p>

CC BY-SA 4.0
2019-04-15T09:34:32.457Z
ok i got it now, i was missing these verification rules. You were talking about full nodes, what about other simple nodes, do they do these verifications too ?
anis herbadji
CC BY-SA 4.0
2019-04-15T09:45:48.463Z
Simple Payment Verification (SPV) nodes that many lightweight wallet uses, downloads only the block headers and not the transactions included in each block. SPV nodes rely on a slightly different method of verification and banks on peers to provide partial views of the relevant parts of the blockchain on demand. SPV nodes link the transaction and the block containing it using Merkle path. Thus it does not have full visibility of the blockchain, but however, it cannot be fooled into assuming that a transaction is included in a block when in fact it isn't.
Ugam Kamat
CC BY-SA 4.0
2019-04-15T09:22:21.570Z
2019-04-15T09:22:21.570Z
Ugam Kamat
<p>I am confused with the block chaining, as i know a block header contains a reference to the previous block header hash with the merkle root and other fields. This header hash is related (computed) to the header and not including the block of transactions, so if the header is tampered the chain will fail. I understood that, but if the transactions in the block are edited, it will not change the header hash only if the merkle root is re-calculated.</p>

<p>My question is when a node receive a block, how it verifies it (just rehashing the header, or recalculating merkle root first then rehashing the header)?</p>

<blockchain><block><hash><merkle-tree>
How chaining the blocks protect against altering data?
anis herbadji
# How chaining the blocks protect against altering data?

(Asked by: username_0 on 2019-04-15)

I am confused with the block chaining, as i know a block header contains a reference to the previous block header hash with the merkle root and other fields. This header hash is related (computed) to the header and not including the block of transactions, so if the header is tampered the chain will fail. I understood that, but if the transactions in the block are edited, it will not change the header hash only if the merkle root is re-calculated.

My question is when a node receive a block, how it verifies it (just rehashing the header, or recalculating merkle root first then rehashing the header)?

**Tags:** blockchain, block, hash, merkle-tree


---

## 1 answers

### Answer by username_1 on 2019-04-15. Score: 1 | Accepted answer

Merkle root is a part of the block header and is calculated based on the transactions included in the block. If transactions in the block are changed, it would change the merkle root in the header. If the merkle root is changed, the block header will change and the header hash which was calculated initially will no longer be valid.

> When a node receive a block, how it verifies it (just rehashing the header, or recalculating merkle root first then rehashing the header)?

When a full node receives a block it performs various checks to ensure the block conforms to the consensus rules. This includes checking that all the transactions in the block are valid. If any particular transaction is not valid, then the entire block will be rejected by the full node. After verification of the transactions, the full node would verify the merkle hash. Then full node will look at the block header and verify the timestamp rule, previous block hash, and other components and then calculate the block header hash and check if it is less than the target. If one of the verification rules fail, the node will reject the block. You can find a complete list of block verification rules [here.](https://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messages)

> **Comments:**
> **username_0**: ok i got it now, i was missing these verification rules. You were talking about full nodes, what about other simple nodes, do they do these verifications too ?  
> **username_1**: Simple Payment Verification (SPV) nodes that many lightweight wallet uses, downloads only the block headers and not the transactions included in each block. SPV nodes rely on a slightly different method of verification and banks on peers to provide partial views of the relevant parts of the blockchain on demand. SPV nodes link the transaction and the block containing it using Merkle path. Thus it does not have full visibility of the blockchain, but however, it cannot be fooled into assuming that a transaction is included in a block when in fact it isn't.  

---

