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

Removed unnecessary EMPTY_STORAGE_MAP_ROOT const #916

Merged
merged 6 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- Implemented `storage_size`, updated storage bounds (#886).
- [BREAKING] Auto-generate `KERNEL_ERRORS` list from the transaction kernel's MASM files and rework error constant names (#906).
- Implement `Serializable` for `FungibleAsset` (#907).
- [BREAKING] Changed type of `EMPTY_STORAGE_MAP_ROOT` constant to `RpoDigst`, which references constant from `miden-crypto` (#916).

## 0.5.1 (2024-08-28) - `miden-objects` crate only

Expand Down
15 changes: 7 additions & 8 deletions objects/src/accounts/storage/map.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use miden_crypto::merkle::EmptySubtreeRoots;

use super::{
AccountError, ByteReader, ByteWriter, Deserializable, DeserializationError, Digest, Felt,
AccountError, ByteReader, ByteWriter, Deserializable, DeserializationError, Digest,
Serializable, Word,
};
use crate::{
Expand All @@ -12,13 +14,10 @@ use crate::{

// ACCOUNT STORAGE MAP
// ================================================================================================

/// Empty storage map root.
pub const EMPTY_STORAGE_MAP_ROOT: Word = [
Felt::new(15321474589252129342),
Felt::new(17373224439259377994),
Felt::new(15071539326562317628),
Felt::new(3312677166725950353),
];
pub const EMPTY_STORAGE_MAP_ROOT: Digest =
*EmptySubtreeRoots::entry(StorageMap::STORAGE_MAP_TREE_DEPTH, 0);

/// Account storage map is a Sparse Merkle Tree of depth 64. It can be used to store more data as
/// there is in plain usage of the storage slots. The root of the SMT consumes one account storage
Expand Down Expand Up @@ -174,6 +173,6 @@ mod tests {
#[test]
fn test_empty_storage_map_constants() {
// If these values don't match, update the constants.
assert_eq!(*StorageMap::default().root(), EMPTY_STORAGE_MAP_ROOT);
assert_eq!(StorageMap::default().root(), EMPTY_STORAGE_MAP_ROOT);
}
}
4 changes: 2 additions & 2 deletions objects/src/accounts/storage/slot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ impl StorageSlot {
pub fn is_default(&self) -> bool {
match self {
StorageSlot::Value(value) => *value == EMPTY_WORD,
StorageSlot::Map(map) => *map.root() == EMPTY_STORAGE_MAP_ROOT,
StorageSlot::Map(map) => map.root() == EMPTY_STORAGE_MAP_ROOT,
}
}

/// Returns the empty [Word] for a storage slot of this type
pub fn default_word(&self) -> Word {
match self {
StorageSlot::Value(_) => EMPTY_WORD,
StorageSlot::Map(_) => EMPTY_STORAGE_MAP_ROOT,
StorageSlot::Map(_) => EMPTY_STORAGE_MAP_ROOT.into(),
}
}

Expand Down
Loading