-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
DatabaseState
abstraction
#11786
DatabaseState
abstraction
#11786
Conversation
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.
one general comment here is that DatabaseState
is a pretty vague name, any way we can find something a bit more descriptive? e.g. something related to state commitment
I agree. How about |
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.
I like StateCommitment
a lot as a name, another note is that this should probably be split up - I think a good strategy for doing this would be:
- PRs for each trait
- Then, PRs for the implementation of each trait by the existing state commitment types
The above two ^ can be combined in the same PR if it's easy.
Finally, the integration withNodeTypes
, full integration oftrait StateCommitment
etc.
Let me know if that makes sense as a general direction! Splitting it up will make it much easier to review and much more likely that these changes can actually get in
Yes this makes sense. I recognise that it is impractical to review / integrate a PR of this size. I think your approach makes sense. I will create an issue with a plan of how we can decompose this into bitesize units of work following your suggestion. |
The intention of this PR was to serve as a proof of concept. The production implementation can be tracked here #11830 |
Overview
The objective of this pull request is to provide abstractions over the the state types in reth, specifically:
StateRoot
StorageRoot
StateProof
StateWitness
KeyHasher
These types should be easily configurable when defining the
NodeTypes
and configuring a node. The motivation behind this abstraction is that at scroll we use a BMPT, the spec of which can be found here. We would like to introduce these abstractions such that we can provide concrete types that work with a BMPT state representation for scroll reth.Implementation
DatabaseState
TraitWe introduce a
DatabaseState
trait which is the object we use to define the concrete types that implement the required operations for the associated objects. The definition of this trait can be seen here:where the
DatabaseStateRoot
,DatabaseStorageRoot
,DatabaseProof
,DatabaseTrieWitness
are the pre-existing traits in reth andKeyHasher
is a new trait that is introduced defined as follows:NodeTypes
ExtensionWe want the concrete
DatabaseState
type to be easily configurable by the use when configuring the node and as such we introduce an associated type toNodeTypes
to enable this:HashedPostState
andPrefixSetLoader
modificationsBoth
HashedPostState
andPrefixSetLoader
have methods which are associated with generating keys by hashing data, we make these methods generic over theKeyHasher
define above.Providers
We modify the required provide objects such that they are generic over the
DatabaseState
using phantom data:HashedPostStateProvider
We want to encapsulate the
DatabaseState
and it's associated types within the state providers and as such we introduce aHashedPostStateProvider
defined as follows such that the types do not leak out of the provider:Default implementation of
DatabaseState
We introduce a default implementation of
DatabaseState
that uses the pre-existing state types as seen below:TODO
Introduce appropriate abstractions for parallel state root.