Skip to content

How are the storage tries structured? #4

Answered by siladu
siladu asked this question in Q&A
Discussion options

You must be logged in to vote

Answer from @ajsutton:

Each contract account has its own (potentially empty) storage: a new merkle trie. This represents the "inter-transactional state" and comes at a cost (in gas).
Some contracts have lots of storage.
Many smaller tries is a good model because you avoid paying the gas costs of hashing lots of small changes to one big trie. (Does besu's BONSAI mode change this?).
A merkle trie is a good choice because you're still able to identify it with a single hash.

If you store the accounts' storage tries by storageRoot rather than the more natural account address, i.e. Map<StorageRoot, StorageTrie> rather than Map<Account, StorageTrie> then this leads to de-duplication since two co…

Replies: 1 comment

Comment options

siladu
Jul 16, 2022
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by siladu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
1 participant