Skip to content

Commit

Permalink
chore: Rename newly added error and regenerate vm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter committed Oct 7, 2024
1 parent 0a84b2f commit a22032e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 55 deletions.
4 changes: 2 additions & 2 deletions miden-lib/asm/kernels/transaction/lib/account.masm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const.ERR_STORAGE_SLOT_INDEX_OUT_OF_BOUNDS=0x0002004E
const.ERR_FAUCET_INVALID_STORAGE_OFFSET=0x0002004F

# Storage offset is invalid for 0 storage size (should be 0)
const.ERR_INVALID_STORAGE_OFFSET_FOR_SIZE=0x00020056
const.ERR_ACCOUNT_INVALID_STORAGE_OFFSET_FOR_SIZE=0x00020056

# CONSTANTS
# =================================================================================================
Expand Down Expand Up @@ -401,7 +401,7 @@ export.validate_procedure_metadata
# assert that if size is 0 then offset is 0
dup.1 eq.0
if.true
dup eq.0 assert.err=ERR_INVALID_STORAGE_OFFSET_FOR_SIZE
dup eq.0 assert.err=ERR_ACCOUNT_INVALID_STORAGE_OFFSET_FOR_SIZE
end
# => [storage_offset, storage_size, index, num_storage_slots, num_account_procedures]

Expand Down
94 changes: 41 additions & 53 deletions miden-tx/src/errors/vm_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@
// 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_<CATEGORY>_...`.
// 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.

// MIDEN VIRTUAL MACHINE ASSERTION ERRORS
// ================================================================================================

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 = 0x00020050;
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_INVALID_STORAGE_OFFSET: u32 = 0x0002004F;
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 = 0x0002004f;
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;
pub const ERR_FAUCET_NON_FUNGIBLE_ASSET_TO_BURN_NOT_FOUND: u32 = 0x00020026;
Expand All @@ -44,20 +47,12 @@ pub const ERR_FUNGIBLE_ASSET_FORMAT_ELEMENT_ONE_MUST_BE_ZERO: u32 = 0x00020033;
pub const ERR_FUNGIBLE_ASSET_FORMAT_ELEMENT_THREE_MUST_BE_FUNGIBLE_FAUCET_ID: u32 = 0x00020035;
pub const ERR_FUNGIBLE_ASSET_FORMAT_ELEMENT_TWO_MUST_BE_ZERO: u32 = 0x00020034;
pub const ERR_FUNGIBLE_ASSET_FORMAT_ELEMENT_ZERO_MUST_BE_WITHIN_LIMITS: u32 = 0x00020036;
<<<<<<< HEAD
pub const ERR_INVALID_FAUCET_STORAGE_OFFSET: u32 = 0x0002004f;
pub const ERR_INVALID_NOTE_IDX: u32 = 0x00020052;
pub const ERR_INVALID_NOTE_TYPE: u32 = 0x00020044;
pub const ERR_INVALID_STORAGE_OFFSET_FOR_SIZE: u32 = 0x00020056;
pub const ERR_INVALID_TX_EXPIRATION_DELTA: u32 = 0x00020055;
=======
pub const ERR_FUNGIBLE_ASSET_PROVIDED_FAUCET_ID_IS_INVALID: u32 = 0x00020041;

>>>>>>> 6acc61a (feat(tx): Include all errors in `asm` dir, group errors by category)
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;
Expand All @@ -70,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;
Expand All @@ -81,46 +76,47 @@ 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;

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;

<<<<<<< HEAD
pub const KERNEL_ERRORS: [(u32, &str); 70] = [
=======
pub const VM_ERRORS: [(u32, &str); 82] = [
>>>>>>> 6acc61a (feat(tx): Include all errors in `asm` dir, group errors by category)
pub const VM_ERRORS: [(u32, &str); 83] = [
(ERR_ACCOUNT_CODE_COMMITMENT_MISMATCH, "Computed account code commitment does not match recorded account code commitment"),
(ERR_ACCOUNT_CODE_IS_NOT_UPDATABLE, "Account code must be updatable for it to be possible to set new code"),
(ERR_ACCOUNT_INSUFFICIENT_NUMBER_OF_ONES, "Account ID must contain at least MIN_ACCOUNT_ONES number of ones"),
(ERR_ACCOUNT_INVALID_STORAGE_OFFSET_FOR_SIZE, "Storage offset is invalid for 0 storage size (should be 0)"),
(ERR_ACCOUNT_IS_NOT_NATIVE, "The current account is not native"),
(ERR_ACCOUNT_NONCE_DID_NOT_INCREASE_AFTER_STATE_CHANGE, "Account nonce did not increase after a state changing transaction"),
(ERR_ACCOUNT_NONCE_INCREASE_MUST_BE_U32, "Account nonce cannot be increased by a greater than u32 value"),
Expand Down Expand Up @@ -153,16 +149,8 @@ pub const VM_ERRORS: [(u32, &str); 82] = [
(ERR_FUNGIBLE_ASSET_FORMAT_ELEMENT_THREE_MUST_BE_FUNGIBLE_FAUCET_ID, "Malformed fungible asset: ASSET[3] must be a valide fungible faucet id"),
(ERR_FUNGIBLE_ASSET_FORMAT_ELEMENT_TWO_MUST_BE_ZERO, "Malformed fungible asset: ASSET[2] must be 0"),
(ERR_FUNGIBLE_ASSET_FORMAT_ELEMENT_ZERO_MUST_BE_WITHIN_LIMITS, "Malformed fungible asset: ASSET[0] exceeds the maximum allowed amount"),
<<<<<<< HEAD
(ERR_INVALID_FAUCET_STORAGE_OFFSET, "Storage offset is invalid for a faucet account (0 is prohibited as it is the reserved data slot for faucets)"),
(ERR_INVALID_NOTE_IDX, "Failed to find note at the given index; index must be within [0, num_of_notes]"),
(ERR_INVALID_NOTE_TYPE, "Invalid note type"),
(ERR_INVALID_STORAGE_OFFSET_FOR_SIZE, "Storage offset is invalid for 0 storage size (should be 0)"),
(ERR_INVALID_TX_EXPIRATION_DELTA, "Input transaction expiration block delta is not within 0x1 and 0xFFFF."),
=======
(ERR_FUNGIBLE_ASSET_PROVIDED_FAUCET_ID_IS_INVALID, "Failed to build the fungible asset because the provided faucet id is not from a fungible faucet"),

>>>>>>> 6acc61a (feat(tx): Include all errors in `asm` dir, group errors by category)
(ERR_KERNEL_PROCEDURE_OFFSET_OUT_OF_BOUNDS, "Provided kernel procedure offset is out of bounds"),

(ERR_NON_FUNGIBLE_ASSET_ALREADY_EXISTS, "Non-fungible asset that already exists in the note cannot be added again"),
Expand Down

0 comments on commit a22032e

Please sign in to comment.