From 199fd3232aa13485d775b823612a36eba275fa81 Mon Sep 17 00:00:00 2001 From: polydez <155382956+polydez@users.noreply.github.com> Date: Fri, 11 Oct 2024 17:56:39 +0500 Subject: [PATCH 1/5] refactor: remove unnecessary const --- objects/src/accounts/storage/map.rs | 17 ++--------------- objects/src/accounts/storage/slot/mod.rs | 11 ++++++++--- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/objects/src/accounts/storage/map.rs b/objects/src/accounts/storage/map.rs index 5e9084f6d..03dccba6f 100644 --- a/objects/src/accounts/storage/map.rs +++ b/objects/src/accounts/storage/map.rs @@ -1,5 +1,5 @@ use super::{ - AccountError, ByteReader, ByteWriter, Deserializable, DeserializationError, Digest, Felt, + AccountError, ByteReader, ByteWriter, Deserializable, DeserializationError, Digest, Serializable, Word, }; use crate::{ @@ -12,13 +12,6 @@ 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), -]; /// 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 @@ -145,7 +138,7 @@ impl Deserializable for StorageMap { mod tests { use miden_crypto::{hash::rpo::RpoDigest, Felt}; - use super::{Deserializable, Serializable, StorageMap, Word, EMPTY_STORAGE_MAP_ROOT}; + use super::{Deserializable, Serializable, StorageMap, Word}; #[test] fn account_storage_serialization() { @@ -170,10 +163,4 @@ mod tests { let bytes = storage_map.to_bytes(); assert_eq!(storage_map, StorageMap::read_from_bytes(&bytes).unwrap()); } - - #[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); - } } diff --git a/objects/src/accounts/storage/slot/mod.rs b/objects/src/accounts/storage/slot/mod.rs index 4cc98a4b4..69f802195 100644 --- a/objects/src/accounts/storage/slot/mod.rs +++ b/objects/src/accounts/storage/slot/mod.rs @@ -1,10 +1,11 @@ +use miden_crypto::merkle::EmptySubtreeRoots; use vm_core::{ utils::{ByteReader, ByteWriter, Deserializable, Serializable}, EMPTY_WORD, ZERO, }; use vm_processor::DeserializationError; -use super::{map::EMPTY_STORAGE_MAP_ROOT, Felt, StorageMap, Word}; +use super::{Felt, StorageMap, Word}; mod r#type; pub use r#type::StorageSlotType; @@ -27,7 +28,9 @@ 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() == EmptySubtreeRoots::entry(StorageMap::STORAGE_MAP_TREE_DEPTH, 0) + }, } } @@ -35,7 +38,9 @@ impl StorageSlot { pub fn default_word(&self) -> Word { match self { StorageSlot::Value(_) => EMPTY_WORD, - StorageSlot::Map(_) => EMPTY_STORAGE_MAP_ROOT, + StorageSlot::Map(_) => { + EmptySubtreeRoots::entry(StorageMap::STORAGE_MAP_TREE_DEPTH, 0).into() + }, } } From eb2c6cc5d81fcf8ba687725b6fe7f6a284a59f50 Mon Sep 17 00:00:00 2001 From: polydez <155382956+polydez@users.noreply.github.com> Date: Fri, 11 Oct 2024 18:00:17 +0500 Subject: [PATCH 2/5] docs: update `CHANGELOG.md` --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d835030c9..2cdc70ba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - [BREAKING] Moved `MAX_NUM_FOREIGN_ACCOUNTS` into `miden-objects` (#904). - 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). +- [BREAKING] Removed unnecessary `EMPTY_STORAGE_MAP_ROOT` constant (#916). ## 0.5.1 (2024-08-28) - `miden-objects` crate only From 6076a5008ba59af8bb0dbaaf75ee6171bd0010ca Mon Sep 17 00:00:00 2001 From: polydez <155382956+polydez@users.noreply.github.com> Date: Mon, 14 Oct 2024 18:10:52 +0500 Subject: [PATCH 3/5] refactor: use constant --- miden-tx/src/errors/tx_kernel_errors.rs | 68 +++++++++++------------- objects/src/accounts/storage/map.rs | 14 ++++- objects/src/accounts/storage/slot/mod.rs | 11 ++-- 3 files changed, 47 insertions(+), 46 deletions(-) diff --git a/miden-tx/src/errors/tx_kernel_errors.rs b/miden-tx/src/errors/tx_kernel_errors.rs index 69f40fcaf..ea7f92805 100644 --- a/miden-tx/src/errors/tx_kernel_errors.rs +++ b/miden-tx/src/errors/tx_kernel_errors.rs @@ -2,38 +2,36 @@ // It is generated by extracting errors from the masm files in the `miden-lib/asm` directory. // // To add a new error, define a constant in masm of the pattern `const.ERR__...`. -// Try to fit the error into a pre-existing category if possible (e.g. Account, Prologue, -// Non-Fungible-Asset, ...). +// Try to fit the error into a pre-existing category if possible (e.g. Account, Prologue, Non-Fungible-Asset, ...). // // The comment directly above the constant will be interpreted as the error message for that error. // KERNEL ASSERTION ERROR // ================================================================================================ -pub const ERR_ACCOUNT_CODE_COMMITMENT_MISMATCH: u32 = 0x0002004c; -pub const ERR_ACCOUNT_CODE_IS_NOT_UPDATABLE: u32 = 0x0002003d; -pub const ERR_ACCOUNT_INSUFFICIENT_NUMBER_OF_ONES: u32 = 0x0002003c; +pub const ERR_ACCOUNT_CODE_COMMITMENT_MISMATCH: u32 = 0x0002004C; +pub const ERR_ACCOUNT_CODE_IS_NOT_UPDATABLE: u32 = 0x0002003D; +pub const ERR_ACCOUNT_INSUFFICIENT_NUMBER_OF_ONES: u32 = 0x0002003C; pub const ERR_ACCOUNT_INVALID_STORAGE_OFFSET_FOR_SIZE: u32 = 0x00020056; pub const ERR_ACCOUNT_IS_NOT_NATIVE: u32 = 0x00020054; pub const ERR_ACCOUNT_NONCE_DID_NOT_INCREASE_AFTER_STATE_CHANGE: u32 = 0x00020009; -pub const ERR_ACCOUNT_NONCE_INCREASE_MUST_BE_U32: u32 = 0x0002003b; -pub const ERR_ACCOUNT_POW_IS_INSUFFICIENT: u32 = 0x0002003f; -pub const ERR_ACCOUNT_PROC_INDEX_OUT_OF_BOUNDS: u32 = 0x0002004b; -pub const ERR_ACCOUNT_PROC_NOT_PART_OF_ACCOUNT_CODE: u32 = 0x0002004a; +pub const ERR_ACCOUNT_NONCE_INCREASE_MUST_BE_U32: u32 = 0x0002003B; +pub const ERR_ACCOUNT_POW_IS_INSUFFICIENT: u32 = 0x0002003F; +pub const ERR_ACCOUNT_PROC_INDEX_OUT_OF_BOUNDS: u32 = 0x0002004B; +pub const ERR_ACCOUNT_PROC_NOT_PART_OF_ACCOUNT_CODE: u32 = 0x0002004A; pub const ERR_ACCOUNT_READING_MAP_VALUE_FROM_NON_MAP_SLOT: u32 = 0x00020049; -pub const ERR_ACCOUNT_SEED_DIGEST_MISMATCH: u32 = 0x0002003e; +pub const ERR_ACCOUNT_SEED_DIGEST_MISMATCH: u32 = 0x0002003E; pub const ERR_ACCOUNT_SETTING_MAP_ITEM_ON_NON_MAP_SLOT: u32 = 0x00020048; pub const ERR_ACCOUNT_SETTING_VALUE_ITEM_ON_NON_VALUE_SLOT: u32 = 0x00020047; pub const ERR_ACCOUNT_STORAGE_COMMITMENT_MISMATCH: u32 = 0x00020058; -pub const ERR_ACCOUNT_TOO_MANY_PROCEDURES: u32 = 0x0002004d; -pub const ERR_ACCOUNT_TOO_MANY_STORAGE_SLOTS: u32 = 0x0002004f; +pub const ERR_ACCOUNT_TOO_MANY_PROCEDURES: u32 = 0x0002004D; +pub const ERR_ACCOUNT_TOO_MANY_STORAGE_SLOTS: u32 = 0x0002004F; pub const ERR_ACCOUNT_TOTAL_ISSUANCE_PROC_CAN_ONLY_BE_CALLED_ON_FUNGIBLE_FAUCET: u32 = 0x00020001; -pub const ERR_EPILOGUE_TOTAL_NUMBER_OF_ASSETS_MUST_STAY_THE_SAME: u32 = 0x0002000a; +pub const ERR_EPILOGUE_TOTAL_NUMBER_OF_ASSETS_MUST_STAY_THE_SAME: u32 = 0x0002000A; pub const ERR_FAUCET_BURN_CANNOT_EXCEED_EXISTING_TOTAL_SUPPLY: u32 = 0x00020023; -pub const ERR_FAUCET_BURN_NON_FUNGIBLE_ASSET_CAN_ONLY_BE_CALLED_ON_NON_FUNGIBLE_FAUCET: u32 = - 0x00020025; +pub const ERR_FAUCET_BURN_NON_FUNGIBLE_ASSET_CAN_ONLY_BE_CALLED_ON_NON_FUNGIBLE_FAUCET: u32 = 0x00020025; pub const ERR_FAUCET_INVALID_STORAGE_OFFSET: u32 = 0x00020057; pub const ERR_FAUCET_NEW_TOTAL_SUPPLY_WOULD_EXCEED_MAX_ASSET_AMOUNT: u32 = 0x00020022; pub const ERR_FAUCET_NON_FUNGIBLE_ASSET_ALREADY_ISSUED: u32 = 0x00020024; @@ -52,7 +50,7 @@ pub const ERR_FUNGIBLE_ASSET_PROVIDED_FAUCET_ID_IS_INVALID: u32 = 0x00020041; pub const ERR_KERNEL_PROCEDURE_OFFSET_OUT_OF_BOUNDS: u32 = 0x00020053; pub const ERR_NON_FUNGIBLE_ASSET_ALREADY_EXISTS: u32 = 0x00020051; -pub const ERR_NON_FUNGIBLE_ASSET_FAUCET_IS_NOT_ORIGIN: u32 = 0x0002003a; +pub const ERR_NON_FUNGIBLE_ASSET_FAUCET_IS_NOT_ORIGIN: u32 = 0x0002003A; pub const ERR_NON_FUNGIBLE_ASSET_FORMAT_ELEMENT_ONE_MUST_BE_FUNGIBLE_FAUCET_ID: u32 = 0x00020037; pub const ERR_NON_FUNGIBLE_ASSET_FORMAT_MOST_SIGNIFICANT_BIT_MUST_BE_ZERO: u32 = 0x00020038; pub const ERR_NON_FUNGIBLE_ASSET_PROVIDED_FAUCET_ID_IS_INVALID: u32 = 0x00020043; @@ -65,7 +63,7 @@ pub const ERR_NOTE_FUNGIBLE_MAX_AMOUNT_EXCEEDED: u32 = 0x00020050; pub const ERR_NOTE_INVALID_INDEX: u32 = 0x00020052; pub const ERR_NOTE_INVALID_NOTE_TYPE_FOR_NOTE_TAG_PREFIX: u32 = 0x00020045; pub const ERR_NOTE_INVALID_TYPE: u32 = 0x00020044; -pub const ERR_NOTE_NUM_OF_ASSETS_EXCEED_LIMIT: u32 = 0x0002002a; +pub const ERR_NOTE_NUM_OF_ASSETS_EXCEED_LIMIT: u32 = 0x0002002A; pub const ERR_NOTE_TAG_MUST_BE_U32: u32 = 0x00020046; pub const ERR_P2IDR_RECLAIM_ACCT_IS_NOT_SENDER: u32 = 0x00020005; @@ -76,25 +74,22 @@ pub const ERR_P2ID_TARGET_ACCT_MISMATCH: u32 = 0x00020003; pub const ERR_P2ID_WRONG_NUMBER_OF_INPUTS: u32 = 0x00020002; pub const ERR_PROLOGUE_EXISTING_ACCOUNT_MUST_HAVE_NON_ZERO_NONCE: u32 = 0x00020018; -pub const ERR_PROLOGUE_GLOBAL_INPUTS_PROVIDED_DO_NOT_MATCH_BLOCK_HASH_COMMITMENT: u32 = 0x0002000b; -pub const ERR_PROLOGUE_INPUT_NOTES_COMMITMENT_MISMATCH: u32 = 0x0002001f; -pub const ERR_PROLOGUE_MISMATCH_OF_ACCOUNT_IDS_FROM_GLOBAL_INPUTS_AND_ADVICE_PROVIDER: u32 = - 0x00020019; -pub const ERR_PROLOGUE_MISMATCH_OF_REFERENCE_BLOCK_MMR_AND_NOTE_AUTHENTICATION_MMR: u32 = - 0x0002001a; -pub const ERR_PROLOGUE_NEW_ACCOUNT_VAULT_MUST_BE_EMPTY: u32 = 0x0002000f; +pub const ERR_PROLOGUE_GLOBAL_INPUTS_PROVIDED_DO_NOT_MATCH_BLOCK_HASH_COMMITMENT: u32 = 0x0002000B; +pub const ERR_PROLOGUE_INPUT_NOTES_COMMITMENT_MISMATCH: u32 = 0x0002001F; +pub const ERR_PROLOGUE_MISMATCH_OF_ACCOUNT_IDS_FROM_GLOBAL_INPUTS_AND_ADVICE_PROVIDER: u32 = 0x00020019; +pub const ERR_PROLOGUE_MISMATCH_OF_REFERENCE_BLOCK_MMR_AND_NOTE_AUTHENTICATION_MMR: u32 = 0x0002001A; +pub const ERR_PROLOGUE_NEW_ACCOUNT_VAULT_MUST_BE_EMPTY: u32 = 0x0002000F; pub const ERR_PROLOGUE_NEW_FUNGIBLE_FAUCET_RESERVED_SLOT_INVALID_TYPE: u32 = 0x00020013; pub const ERR_PROLOGUE_NEW_FUNGIBLE_FAUCET_RESERVED_SLOT_MUST_BE_EMPTY: u32 = 0x00020011; pub const ERR_PROLOGUE_NEW_NON_FUNGIBLE_FAUCET_RESERVED_SLOT_INVALID_TYPE: u32 = 0x00020016; -pub const ERR_PROLOGUE_NEW_NON_FUNGIBLE_FAUCET_RESERVED_SLOT_MUST_BE_VALID_EMPY_SMT: u32 = - 0x00020014; -pub const ERR_PROLOGUE_NUMBER_OF_INPUT_NOTES_EXCEEDS_LIMIT: u32 = 0x0002001e; -pub const ERR_PROLOGUE_NUMBER_OF_NOTE_ASSETS_EXCEEDS_LIMIT: u32 = 0x0002001c; -pub const ERR_PROLOGUE_NUMBER_OF_NOTE_INPUTS_EXCEEDED_LIMIT: u32 = 0x0002001b; +pub const ERR_PROLOGUE_NEW_NON_FUNGIBLE_FAUCET_RESERVED_SLOT_MUST_BE_VALID_EMPY_SMT: u32 = 0x00020014; +pub const ERR_PROLOGUE_NUMBER_OF_INPUT_NOTES_EXCEEDS_LIMIT: u32 = 0x0002001E; +pub const ERR_PROLOGUE_NUMBER_OF_NOTE_ASSETS_EXCEEDS_LIMIT: u32 = 0x0002001C; +pub const ERR_PROLOGUE_NUMBER_OF_NOTE_INPUTS_EXCEEDED_LIMIT: u32 = 0x0002001B; pub const ERR_PROLOGUE_PROVIDED_ACCOUNT_DATA_DOES_NOT_MATCH_ON_CHAIN_COMMITMENT: u32 = 0x00020017; -pub const ERR_PROLOGUE_PROVIDED_INPUT_ASSETS_INFO_DOES_NOT_MATCH_ITS_COMMITMENT: u32 = 0x0002001d; +pub const ERR_PROLOGUE_PROVIDED_INPUT_ASSETS_INFO_DOES_NOT_MATCH_ITS_COMMITMENT: u32 = 0x0002001D; -pub const ERR_STORAGE_SLOT_INDEX_OUT_OF_BOUNDS: u32 = 0x0002004e; +pub const ERR_STORAGE_SLOT_INDEX_OUT_OF_BOUNDS: u32 = 0x0002004E; pub const ERR_SWAP_WRONG_NUMBER_OF_ASSETS: u32 = 0x00020008; pub const ERR_SWAP_WRONG_NUMBER_OF_INPUTS: u32 = 0x00020007; @@ -102,13 +97,12 @@ pub const ERR_SWAP_WRONG_NUMBER_OF_INPUTS: u32 = 0x00020007; pub const ERR_TX_INVALID_EXPIRATION_DELTA: u32 = 0x00020055; pub const ERR_TX_NUMBER_OF_OUTPUT_NOTES_EXCEEDS_LIMIT: u32 = 0x00020020; -pub const ERR_VAULT_ADD_FUNGIBLE_ASSET_FAILED_INITIAL_VALUE_INVALID: u32 = 0x0002002e; +pub const ERR_VAULT_ADD_FUNGIBLE_ASSET_FAILED_INITIAL_VALUE_INVALID: u32 = 0x0002002E; pub const ERR_VAULT_FUNGIBLE_ASSET_AMOUNT_LESS_THAN_AMOUNT_TO_WITHDRAW: u32 = 0x00020030; -pub const ERR_VAULT_FUNGIBLE_MAX_AMOUNT_EXCEEDED: u32 = 0x0002002d; -pub const ERR_VAULT_GET_BALANCE_PROC_CAN_ONLY_BE_CALLED_ON_FUNGIBLE_FAUCET: u32 = 0x0002002b; -pub const ERR_VAULT_HAS_NON_FUNGIBLE_ASSET_PROC_CAN_BE_CALLED_ONLY_WITH_NON_FUNGIBLE_ASSET: u32 = - 0x0002002c; -pub const ERR_VAULT_NON_FUNGIBLE_ASSET_ALREADY_EXISTS: u32 = 0x0002002f; +pub const ERR_VAULT_FUNGIBLE_MAX_AMOUNT_EXCEEDED: u32 = 0x0002002D; +pub const ERR_VAULT_GET_BALANCE_PROC_CAN_ONLY_BE_CALLED_ON_FUNGIBLE_FAUCET: u32 = 0x0002002B; +pub const ERR_VAULT_HAS_NON_FUNGIBLE_ASSET_PROC_CAN_BE_CALLED_ONLY_WITH_NON_FUNGIBLE_ASSET: u32 = 0x0002002C; +pub const ERR_VAULT_NON_FUNGIBLE_ASSET_ALREADY_EXISTS: u32 = 0x0002002F; pub const ERR_VAULT_NON_FUNGIBLE_ASSET_TO_REMOVE_NOT_FOUND: u32 = 0x00020032; pub const ERR_VAULT_REMOVE_FUNGIBLE_ASSET_FAILED_INITIAL_VALUE_INVALID: u32 = 0x00020031; diff --git a/objects/src/accounts/storage/map.rs b/objects/src/accounts/storage/map.rs index 03dccba6f..8ccc7d1df 100644 --- a/objects/src/accounts/storage/map.rs +++ b/objects/src/accounts/storage/map.rs @@ -1,3 +1,5 @@ +use miden_crypto::merkle::EmptySubtreeRoots; + use super::{ AccountError, ByteReader, ByteWriter, Deserializable, DeserializationError, Digest, Serializable, Word, @@ -13,6 +15,10 @@ use crate::{ // ACCOUNT STORAGE MAP // ================================================================================================ +/// Empty storage map root. +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 /// slot. @@ -138,7 +144,7 @@ impl Deserializable for StorageMap { mod tests { use miden_crypto::{hash::rpo::RpoDigest, Felt}; - use super::{Deserializable, Serializable, StorageMap, Word}; + use super::{Deserializable, Serializable, StorageMap, Word, EMPTY_STORAGE_MAP_ROOT}; #[test] fn account_storage_serialization() { @@ -163,4 +169,10 @@ mod tests { let bytes = storage_map.to_bytes(); assert_eq!(storage_map, StorageMap::read_from_bytes(&bytes).unwrap()); } + + #[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); + } } diff --git a/objects/src/accounts/storage/slot/mod.rs b/objects/src/accounts/storage/slot/mod.rs index 69f802195..5e6862e67 100644 --- a/objects/src/accounts/storage/slot/mod.rs +++ b/objects/src/accounts/storage/slot/mod.rs @@ -1,11 +1,10 @@ -use miden_crypto::merkle::EmptySubtreeRoots; use vm_core::{ utils::{ByteReader, ByteWriter, Deserializable, Serializable}, EMPTY_WORD, ZERO, }; use vm_processor::DeserializationError; -use super::{Felt, StorageMap, Word}; +use super::{map::EMPTY_STORAGE_MAP_ROOT, Felt, StorageMap, Word}; mod r#type; pub use r#type::StorageSlotType; @@ -28,9 +27,7 @@ impl StorageSlot { pub fn is_default(&self) -> bool { match self { StorageSlot::Value(value) => *value == EMPTY_WORD, - StorageSlot::Map(map) => { - &map.root() == EmptySubtreeRoots::entry(StorageMap::STORAGE_MAP_TREE_DEPTH, 0) - }, + StorageSlot::Map(map) => map.root() == EMPTY_STORAGE_MAP_ROOT, } } @@ -38,9 +35,7 @@ impl StorageSlot { pub fn default_word(&self) -> Word { match self { StorageSlot::Value(_) => EMPTY_WORD, - StorageSlot::Map(_) => { - EmptySubtreeRoots::entry(StorageMap::STORAGE_MAP_TREE_DEPTH, 0).into() - }, + StorageSlot::Map(_) => EMPTY_STORAGE_MAP_ROOT.into(), } } From e1140b20412a7645ea54f3a26b1ba86a965d84c7 Mon Sep 17 00:00:00 2001 From: polydez <155382956+polydez@users.noreply.github.com> Date: Mon, 14 Oct 2024 18:15:13 +0500 Subject: [PATCH 4/5] docs: update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cdc70ba2..b11f32963 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ - [BREAKING] Moved `MAX_NUM_FOREIGN_ACCOUNTS` into `miden-objects` (#904). - 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). -- [BREAKING] Removed unnecessary `EMPTY_STORAGE_MAP_ROOT` constant (#916). +- [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 From 02fd4d6ecc2aa5fc9ad964d9fd7a4375f3b539f8 Mon Sep 17 00:00:00 2001 From: polydez <155382956+polydez@users.noreply.github.com> Date: Mon, 14 Oct 2024 18:20:14 +0500 Subject: [PATCH 5/5] format: apply rustfmt formatting --- miden-tx/src/errors/tx_kernel_errors.rs | 68 ++++++++++++++----------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/miden-tx/src/errors/tx_kernel_errors.rs b/miden-tx/src/errors/tx_kernel_errors.rs index ea7f92805..69f40fcaf 100644 --- a/miden-tx/src/errors/tx_kernel_errors.rs +++ b/miden-tx/src/errors/tx_kernel_errors.rs @@ -2,36 +2,38 @@ // It is generated by extracting errors from the masm files in the `miden-lib/asm` directory. // // To add a new error, define a constant in masm of the pattern `const.ERR__...`. -// Try to fit the error into a pre-existing category if possible (e.g. Account, Prologue, Non-Fungible-Asset, ...). +// Try to fit the error into a pre-existing category if possible (e.g. Account, Prologue, +// Non-Fungible-Asset, ...). // // The comment directly above the constant will be interpreted as the error message for that error. // KERNEL ASSERTION ERROR // ================================================================================================ -pub const ERR_ACCOUNT_CODE_COMMITMENT_MISMATCH: u32 = 0x0002004C; -pub const ERR_ACCOUNT_CODE_IS_NOT_UPDATABLE: u32 = 0x0002003D; -pub const ERR_ACCOUNT_INSUFFICIENT_NUMBER_OF_ONES: u32 = 0x0002003C; +pub const ERR_ACCOUNT_CODE_COMMITMENT_MISMATCH: u32 = 0x0002004c; +pub const ERR_ACCOUNT_CODE_IS_NOT_UPDATABLE: u32 = 0x0002003d; +pub const ERR_ACCOUNT_INSUFFICIENT_NUMBER_OF_ONES: u32 = 0x0002003c; pub const ERR_ACCOUNT_INVALID_STORAGE_OFFSET_FOR_SIZE: u32 = 0x00020056; pub const ERR_ACCOUNT_IS_NOT_NATIVE: u32 = 0x00020054; pub const ERR_ACCOUNT_NONCE_DID_NOT_INCREASE_AFTER_STATE_CHANGE: u32 = 0x00020009; -pub const ERR_ACCOUNT_NONCE_INCREASE_MUST_BE_U32: u32 = 0x0002003B; -pub const ERR_ACCOUNT_POW_IS_INSUFFICIENT: u32 = 0x0002003F; -pub const ERR_ACCOUNT_PROC_INDEX_OUT_OF_BOUNDS: u32 = 0x0002004B; -pub const ERR_ACCOUNT_PROC_NOT_PART_OF_ACCOUNT_CODE: u32 = 0x0002004A; +pub const ERR_ACCOUNT_NONCE_INCREASE_MUST_BE_U32: u32 = 0x0002003b; +pub const ERR_ACCOUNT_POW_IS_INSUFFICIENT: u32 = 0x0002003f; +pub const ERR_ACCOUNT_PROC_INDEX_OUT_OF_BOUNDS: u32 = 0x0002004b; +pub const ERR_ACCOUNT_PROC_NOT_PART_OF_ACCOUNT_CODE: u32 = 0x0002004a; pub const ERR_ACCOUNT_READING_MAP_VALUE_FROM_NON_MAP_SLOT: u32 = 0x00020049; -pub const ERR_ACCOUNT_SEED_DIGEST_MISMATCH: u32 = 0x0002003E; +pub const ERR_ACCOUNT_SEED_DIGEST_MISMATCH: u32 = 0x0002003e; pub const ERR_ACCOUNT_SETTING_MAP_ITEM_ON_NON_MAP_SLOT: u32 = 0x00020048; pub const ERR_ACCOUNT_SETTING_VALUE_ITEM_ON_NON_VALUE_SLOT: u32 = 0x00020047; pub const ERR_ACCOUNT_STORAGE_COMMITMENT_MISMATCH: u32 = 0x00020058; -pub const ERR_ACCOUNT_TOO_MANY_PROCEDURES: u32 = 0x0002004D; -pub const ERR_ACCOUNT_TOO_MANY_STORAGE_SLOTS: u32 = 0x0002004F; +pub const ERR_ACCOUNT_TOO_MANY_PROCEDURES: u32 = 0x0002004d; +pub const ERR_ACCOUNT_TOO_MANY_STORAGE_SLOTS: u32 = 0x0002004f; pub const ERR_ACCOUNT_TOTAL_ISSUANCE_PROC_CAN_ONLY_BE_CALLED_ON_FUNGIBLE_FAUCET: u32 = 0x00020001; -pub const ERR_EPILOGUE_TOTAL_NUMBER_OF_ASSETS_MUST_STAY_THE_SAME: u32 = 0x0002000A; +pub const ERR_EPILOGUE_TOTAL_NUMBER_OF_ASSETS_MUST_STAY_THE_SAME: u32 = 0x0002000a; pub const ERR_FAUCET_BURN_CANNOT_EXCEED_EXISTING_TOTAL_SUPPLY: u32 = 0x00020023; -pub const ERR_FAUCET_BURN_NON_FUNGIBLE_ASSET_CAN_ONLY_BE_CALLED_ON_NON_FUNGIBLE_FAUCET: u32 = 0x00020025; +pub const ERR_FAUCET_BURN_NON_FUNGIBLE_ASSET_CAN_ONLY_BE_CALLED_ON_NON_FUNGIBLE_FAUCET: u32 = + 0x00020025; pub const ERR_FAUCET_INVALID_STORAGE_OFFSET: u32 = 0x00020057; pub const ERR_FAUCET_NEW_TOTAL_SUPPLY_WOULD_EXCEED_MAX_ASSET_AMOUNT: u32 = 0x00020022; pub const ERR_FAUCET_NON_FUNGIBLE_ASSET_ALREADY_ISSUED: u32 = 0x00020024; @@ -50,7 +52,7 @@ pub const ERR_FUNGIBLE_ASSET_PROVIDED_FAUCET_ID_IS_INVALID: u32 = 0x00020041; pub const ERR_KERNEL_PROCEDURE_OFFSET_OUT_OF_BOUNDS: u32 = 0x00020053; pub const ERR_NON_FUNGIBLE_ASSET_ALREADY_EXISTS: u32 = 0x00020051; -pub const ERR_NON_FUNGIBLE_ASSET_FAUCET_IS_NOT_ORIGIN: u32 = 0x0002003A; +pub const ERR_NON_FUNGIBLE_ASSET_FAUCET_IS_NOT_ORIGIN: u32 = 0x0002003a; pub const ERR_NON_FUNGIBLE_ASSET_FORMAT_ELEMENT_ONE_MUST_BE_FUNGIBLE_FAUCET_ID: u32 = 0x00020037; pub const ERR_NON_FUNGIBLE_ASSET_FORMAT_MOST_SIGNIFICANT_BIT_MUST_BE_ZERO: u32 = 0x00020038; pub const ERR_NON_FUNGIBLE_ASSET_PROVIDED_FAUCET_ID_IS_INVALID: u32 = 0x00020043; @@ -63,7 +65,7 @@ pub const ERR_NOTE_FUNGIBLE_MAX_AMOUNT_EXCEEDED: u32 = 0x00020050; pub const ERR_NOTE_INVALID_INDEX: u32 = 0x00020052; pub const ERR_NOTE_INVALID_NOTE_TYPE_FOR_NOTE_TAG_PREFIX: u32 = 0x00020045; pub const ERR_NOTE_INVALID_TYPE: u32 = 0x00020044; -pub const ERR_NOTE_NUM_OF_ASSETS_EXCEED_LIMIT: u32 = 0x0002002A; +pub const ERR_NOTE_NUM_OF_ASSETS_EXCEED_LIMIT: u32 = 0x0002002a; pub const ERR_NOTE_TAG_MUST_BE_U32: u32 = 0x00020046; pub const ERR_P2IDR_RECLAIM_ACCT_IS_NOT_SENDER: u32 = 0x00020005; @@ -74,22 +76,25 @@ pub const ERR_P2ID_TARGET_ACCT_MISMATCH: u32 = 0x00020003; pub const ERR_P2ID_WRONG_NUMBER_OF_INPUTS: u32 = 0x00020002; pub const ERR_PROLOGUE_EXISTING_ACCOUNT_MUST_HAVE_NON_ZERO_NONCE: u32 = 0x00020018; -pub const ERR_PROLOGUE_GLOBAL_INPUTS_PROVIDED_DO_NOT_MATCH_BLOCK_HASH_COMMITMENT: u32 = 0x0002000B; -pub const ERR_PROLOGUE_INPUT_NOTES_COMMITMENT_MISMATCH: u32 = 0x0002001F; -pub const ERR_PROLOGUE_MISMATCH_OF_ACCOUNT_IDS_FROM_GLOBAL_INPUTS_AND_ADVICE_PROVIDER: u32 = 0x00020019; -pub const ERR_PROLOGUE_MISMATCH_OF_REFERENCE_BLOCK_MMR_AND_NOTE_AUTHENTICATION_MMR: u32 = 0x0002001A; -pub const ERR_PROLOGUE_NEW_ACCOUNT_VAULT_MUST_BE_EMPTY: u32 = 0x0002000F; +pub const ERR_PROLOGUE_GLOBAL_INPUTS_PROVIDED_DO_NOT_MATCH_BLOCK_HASH_COMMITMENT: u32 = 0x0002000b; +pub const ERR_PROLOGUE_INPUT_NOTES_COMMITMENT_MISMATCH: u32 = 0x0002001f; +pub const ERR_PROLOGUE_MISMATCH_OF_ACCOUNT_IDS_FROM_GLOBAL_INPUTS_AND_ADVICE_PROVIDER: u32 = + 0x00020019; +pub const ERR_PROLOGUE_MISMATCH_OF_REFERENCE_BLOCK_MMR_AND_NOTE_AUTHENTICATION_MMR: u32 = + 0x0002001a; +pub const ERR_PROLOGUE_NEW_ACCOUNT_VAULT_MUST_BE_EMPTY: u32 = 0x0002000f; pub const ERR_PROLOGUE_NEW_FUNGIBLE_FAUCET_RESERVED_SLOT_INVALID_TYPE: u32 = 0x00020013; pub const ERR_PROLOGUE_NEW_FUNGIBLE_FAUCET_RESERVED_SLOT_MUST_BE_EMPTY: u32 = 0x00020011; pub const ERR_PROLOGUE_NEW_NON_FUNGIBLE_FAUCET_RESERVED_SLOT_INVALID_TYPE: u32 = 0x00020016; -pub const ERR_PROLOGUE_NEW_NON_FUNGIBLE_FAUCET_RESERVED_SLOT_MUST_BE_VALID_EMPY_SMT: u32 = 0x00020014; -pub const ERR_PROLOGUE_NUMBER_OF_INPUT_NOTES_EXCEEDS_LIMIT: u32 = 0x0002001E; -pub const ERR_PROLOGUE_NUMBER_OF_NOTE_ASSETS_EXCEEDS_LIMIT: u32 = 0x0002001C; -pub const ERR_PROLOGUE_NUMBER_OF_NOTE_INPUTS_EXCEEDED_LIMIT: u32 = 0x0002001B; +pub const ERR_PROLOGUE_NEW_NON_FUNGIBLE_FAUCET_RESERVED_SLOT_MUST_BE_VALID_EMPY_SMT: u32 = + 0x00020014; +pub const ERR_PROLOGUE_NUMBER_OF_INPUT_NOTES_EXCEEDS_LIMIT: u32 = 0x0002001e; +pub const ERR_PROLOGUE_NUMBER_OF_NOTE_ASSETS_EXCEEDS_LIMIT: u32 = 0x0002001c; +pub const ERR_PROLOGUE_NUMBER_OF_NOTE_INPUTS_EXCEEDED_LIMIT: u32 = 0x0002001b; pub const ERR_PROLOGUE_PROVIDED_ACCOUNT_DATA_DOES_NOT_MATCH_ON_CHAIN_COMMITMENT: u32 = 0x00020017; -pub const ERR_PROLOGUE_PROVIDED_INPUT_ASSETS_INFO_DOES_NOT_MATCH_ITS_COMMITMENT: u32 = 0x0002001D; +pub const ERR_PROLOGUE_PROVIDED_INPUT_ASSETS_INFO_DOES_NOT_MATCH_ITS_COMMITMENT: u32 = 0x0002001d; -pub const ERR_STORAGE_SLOT_INDEX_OUT_OF_BOUNDS: u32 = 0x0002004E; +pub const ERR_STORAGE_SLOT_INDEX_OUT_OF_BOUNDS: u32 = 0x0002004e; pub const ERR_SWAP_WRONG_NUMBER_OF_ASSETS: u32 = 0x00020008; pub const ERR_SWAP_WRONG_NUMBER_OF_INPUTS: u32 = 0x00020007; @@ -97,12 +102,13 @@ pub const ERR_SWAP_WRONG_NUMBER_OF_INPUTS: u32 = 0x00020007; pub const ERR_TX_INVALID_EXPIRATION_DELTA: u32 = 0x00020055; pub const ERR_TX_NUMBER_OF_OUTPUT_NOTES_EXCEEDS_LIMIT: u32 = 0x00020020; -pub const ERR_VAULT_ADD_FUNGIBLE_ASSET_FAILED_INITIAL_VALUE_INVALID: u32 = 0x0002002E; +pub const ERR_VAULT_ADD_FUNGIBLE_ASSET_FAILED_INITIAL_VALUE_INVALID: u32 = 0x0002002e; pub const ERR_VAULT_FUNGIBLE_ASSET_AMOUNT_LESS_THAN_AMOUNT_TO_WITHDRAW: u32 = 0x00020030; -pub const ERR_VAULT_FUNGIBLE_MAX_AMOUNT_EXCEEDED: u32 = 0x0002002D; -pub const ERR_VAULT_GET_BALANCE_PROC_CAN_ONLY_BE_CALLED_ON_FUNGIBLE_FAUCET: u32 = 0x0002002B; -pub const ERR_VAULT_HAS_NON_FUNGIBLE_ASSET_PROC_CAN_BE_CALLED_ONLY_WITH_NON_FUNGIBLE_ASSET: u32 = 0x0002002C; -pub const ERR_VAULT_NON_FUNGIBLE_ASSET_ALREADY_EXISTS: u32 = 0x0002002F; +pub const ERR_VAULT_FUNGIBLE_MAX_AMOUNT_EXCEEDED: u32 = 0x0002002d; +pub const ERR_VAULT_GET_BALANCE_PROC_CAN_ONLY_BE_CALLED_ON_FUNGIBLE_FAUCET: u32 = 0x0002002b; +pub const ERR_VAULT_HAS_NON_FUNGIBLE_ASSET_PROC_CAN_BE_CALLED_ONLY_WITH_NON_FUNGIBLE_ASSET: u32 = + 0x0002002c; +pub const ERR_VAULT_NON_FUNGIBLE_ASSET_ALREADY_EXISTS: u32 = 0x0002002f; pub const ERR_VAULT_NON_FUNGIBLE_ASSET_TO_REMOVE_NOT_FOUND: u32 = 0x00020032; pub const ERR_VAULT_REMOVE_FUNGIBLE_ASSET_FAILED_INITIAL_VALUE_INVALID: u32 = 0x00020031;