core: implement state database#32084
Conversation
gballet
left a comment
There was a problem hiding this comment.
I left a few questions, chief of all how you expect the transition pointers to be maintained, how OpenStorageTrie should be handled.
Once this is clear, I can try to port the transition on top of that and see what breaks.
| } | ||
|
|
||
| // stateDB returns the appropriate state database based on the given flag. | ||
| func (s *stateDatabase) stateDB(isVerkle bool) *state.CachingDB { |
There was a problem hiding this comment.
that should really have another name, we find ourselves calling statedb.stateDB() which makes a part of the code that has a ton of confusing names even more confusing because now two things are named the same.
Why not keeping caching database as a name?
| func (s *stateDatabase) hasState(root common.Hash) bool { | ||
| _, err := s.merkle.NodeReader(root) | ||
| if err == nil { | ||
| return true | ||
| } | ||
| _, err = s.verkle.NodeReader(root) | ||
| return err == nil | ||
| } | ||
|
|
There was a problem hiding this comment.
it should be the opposite, verkle primes over merkle, otherwise the transition won't work.
There was a problem hiding this comment.
k, I see that this is just testing whether the state exists, and a same state won't be present in both dbs because they don't have the same hash. I think it's confusing, owing to the transition process, but it makes sense because we don't want to take the slower path until we know it's needed.
| if root == types.EmptyRootHash { | ||
| return &reader{db: db}, nil | ||
| } |
There was a problem hiding this comment.
I don't see why this is needed?
There was a problem hiding this comment.
Because the root node of empty merkle trie won't be persisted in the database.
triedb.NodeReader(types.EmptyRootHash) will return nil without this condition.
There was a problem hiding this comment.
iiuc, the pointers / TransitionState should also be managed at this level? But then I still need to have OpenTrie knowing which epoch I'm at, to figure out which kind of tree needs to be returned.
|
It's outdated, closing it. |
This pull request introduces a new structure: stateDatabase, acting as the entrypoint of state data
and provides another layer of abstraction between Merkle and Verkle data.