3

I have seen that nodes hold a storage trie and state trie. What are those tries and are there these two tries per a contract code (in every copy of the blockchain)?

1 Answer 1

5

There are 4 tries in total. See How many trie's does Ethereum have?

The state trie is globally scoped, and contains a mapping of all known accounts to their state. Each leaf node of the state trie represents an account. The data structure of each leaf node contains details about the account balance, nonce, the code associated with the account, as well as the hash of the root node of...

...the account's storage trie, which is a mapping of integer keys to other integer values.

...and are there these two tries per a contract code (in every copy of the blockchain)?

As above, the contract code is associated with a specific account in the state trie. This is represented by a single leaf node in the trie. Each account will have its own entire storage trie.

5
  • I see, Who updates the state trie? what is the difference between a transaction receipt trie and a transaction trie? is every node in the state trie connect with an account contains a storage trie(of the account)?
    – adi
    Apr 21, 2018 at 20:30
  • The tree is updated whenever there is a state change. (i.e. When a change is made to an existing account, or a new account comes into existence.) All nodes will make the changes to their own copy of the trie when they receive a new block. Yes, each node in the state trie (i.e. the account) has its own storage trie. A transaction trie is per block, and contains a trie of transactions in the block. The receipt trie contains log entries for the transactions in the transactions trie. Apr 28, 2018 at 17:39
  • 1
    See: i.stack.imgur.com/afWDt.jpg Apr 28, 2018 at 17:40
  • "Each node of the state trie represents an account." Not sure if this is technically correct. There are 4 types of nodes, where the leaf node actually contains account details, while the others are used as intermediary steps to arriving at the leaf.
    – Eric
    Jan 3, 2022 at 12:42
  • Hi @Vasily - you're right, thanks for spotting this. I've edited my post accordingly. Thanks again! Jan 3, 2022 at 15:14

Your Answer

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

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