diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d35f55ac..ab71b184c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/objects/src/accounts/storage/map.rs b/objects/src/accounts/storage/map.rs index 5e9084f6d..8ccc7d1df 100644 --- a/objects/src/accounts/storage/map.rs +++ b/objects/src/accounts/storage/map.rs @@ -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::{ @@ -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 @@ -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); } } diff --git a/objects/src/accounts/storage/slot/mod.rs b/objects/src/accounts/storage/slot/mod.rs index 4cc98a4b4..5e6862e67 100644 --- a/objects/src/accounts/storage/slot/mod.rs +++ b/objects/src/accounts/storage/slot/mod.rs @@ -27,7 +27,7 @@ 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, } } @@ -35,7 +35,7 @@ impl StorageSlot { 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(), } }