2

I have some confusions regarding merkle patricia tree..

Q1. As in a binary merkle tree hash of a node is calculated and we combine the hash of two child node to create parent node and so on. State tree is merkle patricia tree, so how hash is calculated in this (means hash of all node or only root node)?

Q2. As in state patricia tree, node is designed on (key, value) pair where key is account of user. So what is the key in transaction tree and reciept tree?

Q3. In patricia tree, (key, value) pair is stored. so here value represents hash of something or original data of account is stored as a leaf node?

2

With reference to the Yellow Paper and this diagram...

(Note I'm referring to them as tries, not trees. I don't suppose it matters too much in this explanation.)

Q1.As in binary merkle tree hash of a node is calculated and we combine the hash of two child node to create parent node and so on.state tree is merkle patricia tree, so how hash is calculated in this(means hash of all node or only root node)

Each node in the world state trie - with the exception of the leaf nodes - potentially has 16 child nodes (it's not a binary tree). Each leaf node represents the account of a given address. The parents of these leaf nodes are created from the hashes of their children. The parents of these nodes are again created from the hashes of their children, and so on, until you reach the root node.

See also: Merkling in Ethereum

Q2. As in state patricia tree, node is designed on (key,value ) pair where key is account no of user. so what is the key in trnsaction tree and reciept tree?

For the transaction trie the key is the transaction ID. For the receipts tree, the key is an index number, where this index number indicates the position of the associated transaction in the block's transaction list.

Q3. In patricia tree, (key, value) pair is stored. so here value represents hash of something or original data of account is stored as a leaf node?

Looking at each trie in turn:

  • State: The value is an RLP data structure containing the account details. This isn't hashed, but the data structure itself contains the hash of the root of the account storage trie. (So Ethereum actually uses 4 tries.)
  • Transaction: The value is a data structure containing details of that transaction. This isn't hashed.
  • Receipts: The value is a tuple containing 4 members. None of which are hashed.

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.