2

Every block in a blockchain contains merkle root value. So for any block, there is some list of transactions and you create a merkle tree based on these transaction. For other blocks, same process will repeated.

My question is: Let us assume that A, B,C,D are transactions and we create a merkle tree and we add the merkle root in block. Now later we got the transactions E,F,G,H so:

  1. whether merkle tree is based on E,F,G,H only
  2. or it is based on A,B,C,D,E,F,G,H .

I want to know that for some block, we created a merkle root value based on A,B,C,D. For others block whether we include previous transaction with new transactions and create a merkle tree. Or with only new transactions, merkle tree is created.

3 Answers 3

3

The blockchain is the mechanism for Bitcoin to converge on one shared state. Participants submit payment orders in the form of unconfirmed transactions to the network from which miners then select a set of transactions into their block candidates. The Merkle root hereby represents a commitment to one specific list of previously unconfirmed, valid transactions. When a new block gets authored, all network participants validate the block and then adopt the new set of balances as the current network state.

Beside the Merkle root as a commitment to this block's transactions, the block header also commits to exactly one preceding block as its parent by including the hash of that predecessor block. As the predecessor in turn committed to it's own predecessor, a new block therefore inductively commits to the full history since the Genesis Block.

Given that each preceding block in turn contains a Merkle root with which it committed to its own set of transactions, any new block also commits indirectly to the full history of all transactions.

Coming back to your example, this means that if Block#1 committed to {A, B, C, D}, the Merkle root in Block#2 would only commit to {E, F, G, H}. However, Block#2 commits to {A, B, C, D} indirectly by declaring Block#1 it's predecessor.

1
  • Thanks for this valuable information. It is really helpful for me. Commented Aug 24, 2019 at 15:05
1

Merkle root is block specific, so each block has a different merkle root. If transactions A-H belong to the same block, then you will have to calculate the merkle root using all the transactions from A-H, if not you will have merkle root containing transaction A-D in Block N and merkle root containing transactions E-H in block N+1.

Blocks commit to the previous block using previousblockhash, which is the double SHA-256 hash of the header of the previous block. Header of a block includes merkle root, previous block hash, timestamp amongst other fields. So by using the hash of the previous block's header in the current block's header you are in essence indirectly committing to the transactions that were included in the previous block thus forming a chain.

2
  • It means that if we collect some transactions at some time, let say T(1) than Merkle root based on these transactions. After some time let say T(2) if we collect some other transaction then Merkle root based on The transactions which we collect at time T(2). Previous transactions are not included in the current Merkle tree to get the Merkle root value. Commented Aug 24, 2019 at 14:48
  • @SanjeevDwivedi Yes that is correct, if you meant transactions in a block. There are unconfirmed transactions that are not included in the blocks (fee used may be low etc.) that will not form the part of the merkle root in any block. The merkle root does not contain transactions from previous blocks. But the use of previous block header hash in the header of the current block indirectly commits to the transactions in the previous block.
    – Ugam Kamat
    Commented Aug 24, 2019 at 17:02
1

For every new block there is a new Merkle tree of transactions. Once the block is included in the blockchain the Merkle tree (and hence the Merkle root) for that block is not changed. In your example, if you are a miner trying to mine a block you can choose to continue with transactions A, B, C and D or form a new Merkle tree with A, B, C, D, E, F, G and H. The larger the transaction fees on E, F, G and H the more likely the miner will switch from trying to mine a block with A, B, C and D to trying to mine a block with A, B, C, D, E, F, G and H.

The key point here is that Merkle trees of transactions cannot be changed once included in the global blockchain but prior to that they can be changed locally as frequently as you wish.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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