From 0a84b2f9d7f095d5c18b19f09f0d27a298e5a52b Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 7 Oct 2024 17:24:29 +0200 Subject: [PATCH] chore(tx): Rename error file to vm errors --- miden-tx/build.rs | 8 +-- miden-tx/src/errors/mod.rs | 2 +- .../{tx_kernel_errors.rs => vm_errors.rs} | 72 +++++++++---------- miden-tx/src/lib.rs | 2 +- .../tests/kernel_tests/test_asset_vault.rs | 2 +- .../src/tests/kernel_tests/test_epilogue.rs | 2 +- .../src/tests/kernel_tests/test_faucet.rs | 2 +- miden-tx/src/tests/kernel_tests/test_note.rs | 2 +- .../src/tests/kernel_tests/test_prologue.rs | 2 +- miden-tx/src/tests/kernel_tests/test_tx.rs | 2 +- 10 files changed, 45 insertions(+), 51 deletions(-) rename miden-tx/src/errors/{tx_kernel_errors.rs => vm_errors.rs} (93%) diff --git a/miden-tx/build.rs b/miden-tx/build.rs index 197e9657d..9f47c3d82 100644 --- a/miden-tx/build.rs +++ b/miden-tx/build.rs @@ -8,12 +8,12 @@ use regex::Regex; use walkdir::WalkDir; const ASM_DIR: &str = "../miden-lib/asm"; -const KERNEL_ERRORS_FILE: &str = "src/errors/tx_kernel_errors.rs"; +const VM_ERRORS_FILE: &str = "src/errors/vm_errors.rs"; fn main() -> Result<()> { // re-build when the MASM code changes println!("cargo:rerun-if-changed={ASM_DIR}"); - println!("cargo:rerun-if-changed={KERNEL_ERRORS_FILE}"); + println!("cargo:rerun-if-changed={VM_ERRORS_FILE}"); // Copies the MASM code to the build directory let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); @@ -71,7 +71,7 @@ fn generate_kernel_error_constants(kernel_source_dir: &Path) -> Result<()> { // Generate the errors file. let error_file_content = generate_kernel_errors(errors)?; - std::fs::write(KERNEL_ERRORS_FILE, error_file_content).into_diagnostic()?; + std::fs::write(VM_ERRORS_FILE, error_file_content).into_diagnostic()?; Ok(()) } @@ -139,7 +139,7 @@ fn generate_kernel_errors(errors: BTreeMap) -> Result< // // The comment directly above the constant will be interpreted as the error message for that error. -// KERNEL ASSERTION ERROR +// MIDEN VIRTUAL MACHINE ASSERTION ERRORS // ================================================================================================ " ) diff --git a/miden-tx/src/errors/mod.rs b/miden-tx/src/errors/mod.rs index 145e5756b..896f1072d 100644 --- a/miden-tx/src/errors/mod.rs +++ b/miden-tx/src/errors/mod.rs @@ -8,7 +8,7 @@ use miden_objects::{ use miden_verifier::VerificationError; use vm_processor::ExecutionError; -pub mod tx_kernel_errors; +pub mod vm_errors; // TRANSACTION EXECUTOR ERROR // ================================================================================================ diff --git a/miden-tx/src/errors/tx_kernel_errors.rs b/miden-tx/src/errors/vm_errors.rs similarity index 93% rename from miden-tx/src/errors/tx_kernel_errors.rs rename to miden-tx/src/errors/vm_errors.rs index 710a30f22..188e1752b 100644 --- a/miden-tx/src/errors/tx_kernel_errors.rs +++ b/miden-tx/src/errors/vm_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 +// 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_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; @@ -59,7 +57,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; @@ -72,7 +70,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; @@ -83,25 +81,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; @@ -109,13 +104,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/miden-tx/src/lib.rs b/miden-tx/src/lib.rs index edb5ddef8..21abd7d10 100644 --- a/miden-tx/src/lib.rs +++ b/miden-tx/src/lib.rs @@ -22,7 +22,7 @@ pub use verifier::TransactionVerifier; mod errors; pub use errors::{ - tx_kernel_errors::VM_ERRORS, AuthenticationError, DataStoreError, TransactionExecutorError, + vm_errors::VM_ERRORS, AuthenticationError, DataStoreError, TransactionExecutorError, TransactionProverError, TransactionVerifierError, }; diff --git a/miden-tx/src/tests/kernel_tests/test_asset_vault.rs b/miden-tx/src/tests/kernel_tests/test_asset_vault.rs index dbcc39f59..dfbcb713b 100644 --- a/miden-tx/src/tests/kernel_tests/test_asset_vault.rs +++ b/miden-tx/src/tests/kernel_tests/test_asset_vault.rs @@ -18,7 +18,7 @@ use miden_objects::{ use super::{Felt, Word, ONE, ZERO}; use crate::{ assert_execution_error, - errors::tx_kernel_errors::{ + errors::vm_errors::{ ERR_VAULT_FUNGIBLE_ASSET_AMOUNT_LESS_THAN_AMOUNT_TO_WITHDRAW, ERR_VAULT_FUNGIBLE_MAX_AMOUNT_EXCEEDED, ERR_VAULT_GET_BALANCE_PROC_CAN_ONLY_BE_CALLED_ON_FUNGIBLE_FAUCET, diff --git a/miden-tx/src/tests/kernel_tests/test_epilogue.rs b/miden-tx/src/tests/kernel_tests/test_epilogue.rs index 58ab507be..e58a527ff 100644 --- a/miden-tx/src/tests/kernel_tests/test_epilogue.rs +++ b/miden-tx/src/tests/kernel_tests/test_epilogue.rs @@ -13,7 +13,7 @@ use vm_processor::{Felt, ProcessState, ONE}; use super::{output_notes_data_procedure, ZERO}; use crate::{ assert_execution_error, - errors::tx_kernel_errors::{ + errors::vm_errors::{ ERR_ACCOUNT_NONCE_DID_NOT_INCREASE_AFTER_STATE_CHANGE, ERR_EPILOGUE_TOTAL_NUMBER_OF_ASSETS_MUST_STAY_THE_SAME, ERR_TX_INVALID_EXPIRATION_DELTA, }, diff --git a/miden-tx/src/tests/kernel_tests/test_faucet.rs b/miden-tx/src/tests/kernel_tests/test_faucet.rs index fca0468b7..d579148d9 100644 --- a/miden-tx/src/tests/kernel_tests/test_faucet.rs +++ b/miden-tx/src/tests/kernel_tests/test_faucet.rs @@ -20,7 +20,7 @@ use vm_processor::{Felt, ProcessState}; use super::ONE; use crate::{ assert_execution_error, - errors::tx_kernel_errors::{ + errors::vm_errors::{ ERR_FAUCET_BURN_NON_FUNGIBLE_ASSET_CAN_ONLY_BE_CALLED_ON_NON_FUNGIBLE_FAUCET, ERR_FAUCET_NEW_TOTAL_SUPPLY_WOULD_EXCEED_MAX_ASSET_AMOUNT, ERR_FAUCET_NON_FUNGIBLE_ASSET_ALREADY_ISSUED, diff --git a/miden-tx/src/tests/kernel_tests/test_note.rs b/miden-tx/src/tests/kernel_tests/test_note.rs index c1eee1b41..e754cfbef 100644 --- a/miden-tx/src/tests/kernel_tests/test_note.rs +++ b/miden-tx/src/tests/kernel_tests/test_note.rs @@ -9,7 +9,7 @@ use vm_processor::{ProcessState, EMPTY_WORD, ONE}; use super::{Felt, Process, ZERO}; use crate::{ assert_execution_error, - errors::tx_kernel_errors::ERR_NOTE_ATTEMPT_TO_ACCESS_NOTE_INPUTS_FROM_INCORRECT_CONTEXT, + errors::vm_errors::ERR_NOTE_ATTEMPT_TO_ACCESS_NOTE_INPUTS_FROM_INCORRECT_CONTEXT, testing::{ utils::input_note_data_ptr, MockHost, TransactionContext, TransactionContextBuilder, }, diff --git a/miden-tx/src/tests/kernel_tests/test_prologue.rs b/miden-tx/src/tests/kernel_tests/test_prologue.rs index 4c52fc8a4..68e2a9146 100644 --- a/miden-tx/src/tests/kernel_tests/test_prologue.rs +++ b/miden-tx/src/tests/kernel_tests/test_prologue.rs @@ -34,7 +34,7 @@ use vm_processor::{AdviceInputs, ONE}; use super::{Felt, Process, Word, ZERO}; use crate::{ assert_execution_error, - errors::tx_kernel_errors::{ + errors::vm_errors::{ ERR_ACCOUNT_SEED_DIGEST_MISMATCH, ERR_PROLOGUE_NEW_FUNGIBLE_FAUCET_RESERVED_SLOT_MUST_BE_EMPTY, ERR_PROLOGUE_NEW_NON_FUNGIBLE_FAUCET_RESERVED_SLOT_MUST_BE_VALID_EMPY_SMT, diff --git a/miden-tx/src/tests/kernel_tests/test_tx.rs b/miden-tx/src/tests/kernel_tests/test_tx.rs index a0b3c57b8..7d28f035a 100644 --- a/miden-tx/src/tests/kernel_tests/test_tx.rs +++ b/miden-tx/src/tests/kernel_tests/test_tx.rs @@ -23,7 +23,7 @@ use miden_objects::{ use super::{Felt, ProcessState, Word, ONE, ZERO}; use crate::{ assert_execution_error, - errors::tx_kernel_errors::{ + errors::vm_errors::{ ERR_NON_FUNGIBLE_ASSET_ALREADY_EXISTS, ERR_TX_NUMBER_OF_OUTPUT_NOTES_EXCEEDS_LIMIT, }, testing::TransactionContextBuilder,