-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(primitives/state-machine) TrieBackend
implementation
#4318
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timwu20
force-pushed
the
tim/trie-backend
branch
from
November 5, 2024 19:15
e3a0c95
to
153c142
Compare
timwu20
force-pushed
the
tim/trie-backend
branch
from
November 5, 2024 20:31
22e08a4
to
0b3e9da
Compare
timwu20
force-pushed
the
tim/triedb-iterators-hashdb
branch
from
November 5, 2024 20:39
9877caa
to
a81ff1b
Compare
timwu20
force-pushed
the
tim/trie-backend
branch
3 times, most recently
from
November 6, 2024 02:52
b24ff73
to
e44ddc8
Compare
timwu20
force-pushed
the
tim/triedb-iterators-hashdb
branch
from
November 6, 2024 03:04
e2449c1
to
95f5c35
Compare
timwu20
force-pushed
the
tim/trie-backend
branch
from
November 6, 2024 03:04
e44ddc8
to
1863c01
Compare
timwu20
requested review from
EclesioMeloJunior,
jimjbrettj and
P1sar
as code owners
November 6, 2024 04:06
timwu20
force-pushed
the
tim/triedb-iterators-hashdb
branch
from
November 6, 2024 14:46
95f5c35
to
a907f8a
Compare
timwu20
force-pushed
the
tim/trie-backend
branch
from
November 6, 2024 14:47
1863c01
to
f571741
Compare
timwu20
force-pushed
the
tim/trie-backend
branch
from
November 6, 2024 20:20
9567398
to
856edc4
Compare
dimartiro
approved these changes
Nov 9, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits but LGTM
Base automatically changed from
tim/triedb-iterators-hashdb
to
refactor/client-db
November 13, 2024 07:43
timwu20
force-pushed
the
tim/trie-backend
branch
from
November 13, 2024 08:13
856edc4
to
ae63560
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
go test -tags integration github.com/ChainSafe/gossamer
Issues
closes #3901 #3836