You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main goal of this is to avoid writing the trie to db every time we update it. This can be used both to commit to db only at the end of a block, or even at the end of multiple blocks if we're syncing/importing.
Ideally, be it for hashing or just regular updating, we want to use everything in-memory. That is, modify in memory, hash in memory, create nodes in memory, etc. Deletions might be a bit trickier, but they shouldn't really happen for now. We also need a way to apply the changes from the cache to the db.
Low level goal
The technical explanation of the problem lies is the commit function. It does three things:
Calculates all hashes.
Moves everything to disk.
empties the cache
This mans that the cache nowadays is actually a buffer, only used before flushing to disk. We know what's new and what's not by checking the cache.
This coupling prevents us from maintaining the cache between blocks, forces us to write to the db and other problems.
What we need to do
Ideally, we need a TrieState.get_root function that only returns the hash and calculates whatever is missing. It shouldn't delete everything from the cache, nor move anything to db.
We need the cache to have it's own policy and size. For now, let's use FIFO policy and size big enough to fit 100000 nodes. We can do a better policy or configure it better later.
The cache will take care of writing to the db automatically without any request from the outside. It will write every node that is removed from the cache.
The text was updated successfully, but these errors were encountered:
High level goal
The main goal of this is to avoid writing the trie to db every time we update it. This can be used both to commit to db only at the end of a block, or even at the end of multiple blocks if we're syncing/importing.
Ideally, be it for hashing or just regular updating, we want to use everything in-memory. That is, modify in memory, hash in memory, create nodes in memory, etc. Deletions might be a bit trickier, but they shouldn't really happen for now. We also need a way to apply the changes from the cache to the db.
Low level goal
The technical explanation of the problem lies is the
commit
function. It does three things:This mans that the cache nowadays is actually a buffer, only used before flushing to disk. We know what's new and what's not by checking the cache.
This coupling prevents us from maintaining the cache between blocks, forces us to write to the db and other problems.
What we need to do
TrieState.get_root
function that only returns the hash and calculates whatever is missing. It shouldn't delete everything from the cache, nor move anything to db.The text was updated successfully, but these errors were encountered: