Skip to content
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

Question: Hashed Key Trie Traversal #12163

Closed
frisitano opened this issue Oct 29, 2024 · 2 comments
Closed

Question: Hashed Key Trie Traversal #12163

frisitano opened this issue Oct 29, 2024 · 2 comments
Labels
C-enhancement New feature or request S-needs-triage This issue needs to be labelled S-stale This issue/PR is stale and will close with no further activity

Comments

@frisitano
Copy link
Contributor

frisitano commented Oct 29, 2024

Hashed Key Trie Traversal

As part of our ambitions at Scroll to leverage reth as a rollup node we are attempting to implement concrete types for our StateCommitment abstraction #11830. With this effort, we would like to reuse existing reth infrastructure such as HashedCursorFactory. This component is sensitive to ordering which is provided by the key of the account (hashed address) or storage slot (hashed slot index). In Ethereum's trie, the key is converted into nibbles and traversed from the most significant nibble to the least significant nibble. In scroll the key is traversed one bit at a time from the least significant bit to the most significant bit. Due to the difference in the trie traversal method, this impacts the order in which nodes should be provided to the HashBuilder.

A solution to this would be to modify the way that hashed keys are produced. We already have an abstraction to allow for key hashing in #11842. The idea would be to introduce a transformation step after hashing keys in the KeyHasher. This step would reverse the endianness of the keys from big-endian to little-endian and also reverse the bits in each byte. After this transformation, the ordering of the keys will conform with their position in the trie as required by the components of reth. From my initial inspection, the implications of changing the hashed key representation should not impact anything else other than the trie-related components of reth. However, I would ask collaborators/maintainers if they are aware of any issues with this approach and if this is reasonable.

Additional context

No response

@frisitano frisitano added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Oct 29, 2024
@frisitano frisitano changed the title Question: Hashed key trie traversal Question: Hashed Key Trie Traversal Oct 29, 2024
Copy link
Contributor

This issue is stale because it has been open for 21 days with no activity.

@github-actions github-actions bot added the S-stale This issue/PR is stale and will close with no further activity label Nov 20, 2024
@frisitano
Copy link
Contributor Author

I've implemented this pattern in scroll-tech#36 and have StateRoot components working with scrolls binary Merkle-Patricia trie.

@github-project-automation github-project-automation bot moved this from Todo to Done in Reth Tracker Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement New feature or request S-needs-triage This issue needs to be labelled S-stale This issue/PR is stale and will close with no further activity
Projects
Archived in project
Development

No branches or pull requests

1 participant