3

As I understand it, the leaf node of the state trie has account data. The account data has a storage root, and the variables of the contract are stored in the leaf node of the storage root.

But what are the benefits of having such a structure? In order to access the value of contract variables, we need to access the branch node {height of mpt} * 2 times

Instead of implementing as above, if remove storage root from account data in state trie and set the key path of contract storage data to leaf node as sha256 (contract_address + variable_index), then we need to access the branch node {height of mpt}

What are the benefits of ethereum nested trie structure?

1

1 Answer 1

0

The primary purpose of the MPT state trie is hashing.

Because you can find the hash of the whole state in the block header (as the state root), you can make sure your state database (and information about all balances and other values) are valid.

The trie structure allows to update this state hash in logarithmic time - without the need for reading the whole state database to get the hash of the state.

Dividing the state trie into tries of states of individual accounts allows to get the state hash of the given contract.

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.