statemachine.Backend is the interface that statemachine.TrieBackend implements. It is used to read from state which is backed by TrieDB, as well as iteration through iterators, and calculate state roots.
statemachine.TrieBackend
statemachine.TrieBackend implements the statemachine.Backend interface. The constructor NewTrieBackend takes as parameters an implementation of the TrieCacheProvider interface as well as an optional recorder.Recorder for node recording and eventual state proof generation. The storage that is read from is an implementation of TrieBackendStorage with an associated root hash to look up.
statemachine.ephemeral
ephemeral is private type to facilitate overlayed changes provided by a trie.PrefixedMemoryDB as the overlay level, while fetching from the underlying TrieBackendStorage when the hash isn't found in the overlay. This implements HashDB and is used as a n ephemeral storage layer for TrieBackend.
statemachine.MemoryDBTrieBackend
MemoryDBTrieBackend is a helper type that creates a TrieBackend where a trie.PrefixedMemoryDB is used as underlying storage. Currently only used in tests but I've exported it for now since it will be used in future work.
trie.SharedTrieCache
SharedTrieCache is used to hold all the trie nodes and values for all operations to the state. Within SharedTrieCache consists of both sharedNodeCache and sharedValueCache instances. There should only be one instance of a SharedTrieCache for a node.
trie.LocalTrieCache
SharedTrieCache.LocalTrieCache() is used to create a LocalTrieCache instance which will get merged back to the parent SharedTrieCache after state changes are processed and LocalTrieCache.Commit() is called.
trie.TrieCache
LocalTrieCache.TrieCache(storageRoot H) is used to create a TrieCache instance which implements triedb.TrieCache interface. TrieCache.MergeInto(ltc *LocalTrieCache, storageRoot H) is used to merge it back to the LocalTrieCache.
costlru.LRU
costlru.LRU is a wrapper around freelru.LRU to constrain the LRU based on the cost. The cost used in the various caches is byte size.
recorder.Recorder
Recorder is used to generate a compatible triedb.TrieRecorder using the private trieRecorder type. The recorder supports transactions which can be rolled back.
Tests
go test -tags integration github.com/ChainSafe/gossamer
Changes
statemachine.Backend
statemachine.Backend
is the interface thatstatemachine.TrieBackend
implements. It is used to read from state which is backed byTrieDB
, as well as iteration through iterators, and calculate state roots.statemachine.TrieBackend
statemachine.TrieBackend
implements thestatemachine.Backend
interface. The constructorNewTrieBackend
takes as parameters an implementation of theTrieCacheProvider
interface as well as an optionalrecorder.Recorder
for node recording and eventual state proof generation. The storage that is read from is an implementation ofTrieBackendStorage
with an associated root hash to look up.statemachine.ephemeral
ephemeral
is private type to facilitate overlayed changes provided by atrie.PrefixedMemoryDB
as the overlay level, while fetching from the underlyingTrieBackendStorage
when the hash isn't found in the overlay. This implementsHashDB
and is used as a n ephemeral storage layer forTrieBackend
.statemachine.MemoryDBTrieBackend
MemoryDBTrieBackend
is a helper type that creates aTrieBackend
where atrie.PrefixedMemoryDB
is used as underlying storage. Currently only used in tests but I've exported it for now since it will be used in future work.trie.SharedTrieCache
SharedTrieCache
is used to hold all the trie nodes and values for all operations to the state. WithinSharedTrieCache
consists of bothsharedNodeCache
andsharedValueCache
instances. There should only be one instance of aSharedTrieCache
for a node.trie.LocalTrieCache
SharedTrieCache.LocalTrieCache()
is used to create aLocalTrieCache
instance which will get merged back to the parentSharedTrieCache
after state changes are processed andLocalTrieCache.Commit()
is called.trie.TrieCache
LocalTrieCache.TrieCache(storageRoot H)
is used to create aTrieCache
instance which implementstriedb.TrieCache
interface.TrieCache.MergeInto(ltc *LocalTrieCache, storageRoot H)
is used to merge it back to theLocalTrieCache
.costlru.LRU
costlru.LRU
is a wrapper aroundfreelru.LRU
to constrain the LRU based on the cost. The cost used in the various caches is byte size.recorder.Recorder
Recorder
is used to generate a compatibletriedb.TrieRecorder
using the privatetrieRecorder
type. The recorder supports transactions which can be rolled back.Tests
Issues
closes #3901 #3836