-
Notifications
You must be signed in to change notification settings - Fork 104
feat: Introduce Word wrapper for storage map keys #2124
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
base: next
Are you sure you want to change the base?
Conversation
|
@PhilippGackstatter there are some more changes to be made but I wanted get your opinion on the general direction of this change before that. |
PhilippGackstatter
left a comment
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.
@varun-doshi Thank you for working on this! I took a first look and the general direction is the right one 👍
| #[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)] | ||
| pub struct StorageMapKey(Word); |
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.
We should soon have the ability to add #[derive(WordWrapper)] introduced in #2108, and once that is merged we should add it.
| use crate::Felt; | ||
|
|
||
| #[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)] | ||
| pub struct HashedStorageMapKey(Word); |
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.
Same here regarding adding WordWrapper.
| } | ||
|
|
||
| /// Returns the leaf index of a map key. | ||
| pub fn hashed_map_key_to_leaf_index(&self) -> Felt { |
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.
This could look just like AssetVault::to_leaf_index:
miden-base/crates/miden-objects/src/asset/vault/vault_key.rs
Lines 64 to 67 in 0cd80af
| /// Returns the leaf index of a vault key. | |
| pub fn to_leaf_index(&self) -> LeafIndex<SMT_DEPTH> { | |
| LeafIndex::<SMT_DEPTH>::from(self.0) | |
| } |
|
@varun-doshi is this still on your radar? |
Fixes #1864