-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Tracking: StateCommitment
abstraction
#11830
Comments
Just added to the tracking issue @Thegaram |
StateCommitment
abstractionStateCommitment
abstraction
This issue is stale because it has been open for 21 days with no activity. |
We have had a change of strategy at Scroll and we will no longer be using the binary Merkle Patricia trie with Poseidon key hashing. Instead, we will be migrating to native MPT, however, we would still like to land this feature in a more conservative fashion. The primary source of the invasiveness of the proposed change was the modified key hashing scheme. If we instead continue to use the standard keccak key hashing scheme the solution becomes much simpler with no need for pub trait HashBuilderT {
pub fn with_updates(mut self, retain_updates: bool) -> Self;
pub fn with_proof_retainer(mut self, retainer: ProofRetainer) -> Self;
pub fn set_updates(&mut self, retain_updates: bool);
pub fn split(mut self) -> (Self, HashMap<Nibbles, BranchNodeCompact>);
pub fn take_proof_nodes(&mut self) -> ProofNodes;
pub fn updates_len(&self) -> usize;
pub fn add_leaf(&mut self, key: Nibbles, value: &[u8]);
pub fn add_branch(&mut self, key: Nibbles, value: B256, stored_in_database: bool);
pub fn root(&mut self) -> B256;
} We can then implement this trait on the different hash builder implementations as seen in the mpt and bmpt examples below: We would then make the consumers of the reth/crates/trie/trie/src/trie.rs Lines 21 to 37 in 3e07d65
We would use the generic I think this yields a far less invasive change and still fulfills the function of allowing for generic state commitment. If we have an agreement on this new approach I will back out previous changes related to key hashing and then create a PR for the proposed solution. |
thanks a lot for the update @frisitano |
I don't agree with the approach to abstract the hash builder. It's abstracting over a concrete implementation detail (the hash builder), rather than providing a good abstraction and API for implementing the state root. For example, we recently reimplemented the state root computation with what we call the sparse trie. The calculation involves:
And this results in a very different internal architecture, and a very different API, than the hash builder. If we were to introduce this abstraction, it would be difficult / impossible to implement the sparse trie. So I would prefer we go a different route, and think about what a state commitment abstraction would need to look like from first principles |
We currently have the following abstraction in place: reth/crates/trie/db/src/commitment.rs Lines 10 to 22 in fd0e9dc
With a concrete implementation for ethereum mpt: reth/crates/trie/db/src/commitment.rs Lines 24 to 39 in fd0e9dc
I propose that we remove the Let me know your thoughts. Would this introduce the correct API? |
Describe the feature
Overview
This issue will be used to plan the implementation of the
StateCommitment
implementation. TheStateCommitment
will be used to provide an abstraction over the types associated with the state commitment. This will allow reth to be used with different state representations configured by the user. Initial POC implemented here.Plan
We will implement the
StateCommitment
via the following units of work:StateCommitment
trait, integrate withNodeTypes
and provide MPT implementation. - feat: introduce StateCommitment type #11842StateCommitment
types within providers. - Introduce StateCommitment in StateProviders #12602HashedPostStateProvider
and refactor methods onHashedPostState
andPrefixSetLoader
to be generic over theKeyHasher
- IntroduceHashedPostStateProvider
#12607HashedStorageProvider
- IntroduceHashedStorageProvider
#12894KeyHasherProvider
- IntroduceKeyHasherProvider
#12895Refactor codebase to leverage
StateCommitment
types for all operations:StateRootProviderExt
and Integrate withStateCommitment
#12896Additional context
#11786
Tasks
HashedPostStateProvider
#12607HashedStorageProvider
#12894KeyHasherProvider
#12895StateRootProviderExt
and Integrate withStateCommitment
#12896The text was updated successfully, but these errors were encountered: