Skip to content

Commit

Permalink
chore(tx): Rename error file to vm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter committed Oct 7, 2024
1 parent eab26e0 commit 0a84b2f
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 51 deletions.
8 changes: 4 additions & 4 deletions miden-tx/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(())
}
Expand Down Expand Up @@ -139,7 +139,7 @@ fn generate_kernel_errors(errors: BTreeMap<String, (String, String)>) -> 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
// ================================================================================================
"
)
Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ================================================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_<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.

// 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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -83,39 +81,35 @@ 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;

Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/tests/kernel_tests/test_asset_vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/tests/kernel_tests/test_epilogue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/tests/kernel_tests/test_faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/tests/kernel_tests/test_note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/tests/kernel_tests/test_prologue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/tests/kernel_tests/test_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0a84b2f

Please sign in to comment.