From bdc1d78ebe7b4095f3a06154b7ab49eb876fd907 Mon Sep 17 00:00:00 2001 From: giwaov Date: Tue, 14 Apr 2026 11:22:12 +0100 Subject: [PATCH] refactor: use constants from kernel::memory module directly Replace 16 simple push-constant procedures in memory.masm with direct constant imports using use \::memory::CONSTANT_NAME and push.CONSTANT_NAME at call sites. This removes unnecessary procedure call overhead for procedures that simply push a constant value onto the stack. Replaced procedures: - get_input_vault_root_ptr -> INPUT_VAULT_ROOT_PTR - get_output_vault_root_ptr -> OUTPUT_VAULT_ROOT_PTR - get_tx_script_root_ptr -> TX_SCRIPT_ROOT_PTR - get_block_data_ptr -> BLOCK_DATA_SECTION_OFFSET - get_partial_blockchain_ptr -> PARTIAL_BLOCKCHAIN_PTR - get_partial_blockchain_peaks_ptr -> PARTIAL_BLOCKCHAIN_PEAKS_PTR - get_native_account_data_ptr -> NATIVE_ACCOUNT_DATA_PTR - get_account_data_length -> ACCOUNT_DATA_LENGTH - get_max_foreign_account_ptr -> MAX_FOREIGN_ACCOUNT_PTR - get_account_delta_fungible_asset_ptr -> ACCOUNT_DELTA_FUNGIBLE_ASSET_PTR - get_account_delta_non_fungible_asset_ptr -> ACCOUNT_DELTA_NON_FUNGIBLE_ASSET_PTR - get_output_note_data_offset -> OUTPUT_NOTE_SECTION_OFFSET - get_kernel_procedures_ptr -> KERNEL_PROCEDURES_PTR - get_link_map_region_start_ptr -> LINK_MAP_REGION_START_PTR - get_link_map_region_end_ptr -> LINK_MAP_REGION_END_PTR - get_link_map_entry_size -> LINK_MAP_ENTRY_SIZE Closes #2415 --- .../asm/kernels/transaction/api.masm | 3 +- .../asm/kernels/transaction/lib/account.masm | 9 +- .../transaction/lib/account_delta.masm | 22 ++- .../asm/kernels/transaction/lib/epilogue.masm | 6 +- .../asm/kernels/transaction/lib/faucet.masm | 9 +- .../asm/kernels/transaction/lib/link_map.masm | 9 +- .../asm/kernels/transaction/lib/memory.masm | 175 +----------------- .../asm/kernels/transaction/lib/prologue.masm | 14 +- .../asm/kernels/transaction/main.masm | 3 +- .../kernels/transaction/tx_script_main.masm | 3 +- 10 files changed, 50 insertions(+), 203 deletions(-) diff --git a/crates/miden-protocol/asm/kernels/transaction/api.masm b/crates/miden-protocol/asm/kernels/transaction/api.masm index 33654d5543..594d80a6fa 100644 --- a/crates/miden-protocol/asm/kernels/transaction/api.masm +++ b/crates/miden-protocol/asm/kernels/transaction/api.masm @@ -10,6 +10,7 @@ use $kernel::tx use $kernel::memory::UPCOMING_FOREIGN_PROCEDURE_PTR use $kernel::memory::UPCOMING_FOREIGN_PROC_INPUT_VALUE_15_PTR +use $kernel::memory::KERNEL_PROCEDURES_PTR use miden::core::word @@ -1534,7 +1535,7 @@ pub proc exec_kernel_proc # => [procedure_offset, , ] # compute the memory pointer at which desired procedure is stored - mul.4 exec.memory::get_kernel_procedures_ptr add + mul.4 push.KERNEL_PROCEDURES_PTR add # => [procedure_pointer, , ] # execute loaded procedure diff --git a/crates/miden-protocol/asm/kernels/transaction/lib/account.masm b/crates/miden-protocol/asm/kernels/transaction/lib/account.masm index 83854cd6af..a6d40b16ec 100644 --- a/crates/miden-protocol/asm/kernels/transaction/lib/account.masm +++ b/crates/miden-protocol/asm/kernels/transaction/lib/account.masm @@ -8,6 +8,9 @@ use $kernel::constants::STORAGE_SLOT_TYPE_VALUE use $kernel::memory use $kernel::memory::ACCT_ID_SUFFIX_OFFSET use $kernel::memory::ACCT_ID_PREFIX_OFFSET +use $kernel::memory::ACCOUNT_DATA_LENGTH +use $kernel::memory::MAX_FOREIGN_ACCOUNT_PTR +use $kernel::memory::NATIVE_ACCOUNT_DATA_PTR use miden::core::collections::smt use miden::core::collections::sorted_array use miden::core::crypto::hashes::rpo256 @@ -1719,7 +1722,7 @@ end pub proc get_account_data_ptr # move pointer one account block back so that the first account pointer in the cycle will point # to the native account - exec.memory::get_native_account_data_ptr exec.memory::get_account_data_length sub + push.NATIVE_ACCOUNT_DATA_PTR push.ACCOUNT_DATA_LENGTH sub # => [curr_account_ptr, foreign_account_id_prefix, foreign_account_id_suffix] # push the pad element onto the stack: it will represent the `is_equal_id` flag during the cycle @@ -1736,7 +1739,7 @@ pub proc get_account_data_ptr # => [curr_account_ptr, foreign_account_id_prefix, foreign_account_id_suffix] # move the current account pointer to the next account data block - exec.memory::get_account_data_length add + push.ACCOUNT_DATA_LENGTH add # => [curr_account_ptr', foreign_account_id_prefix, foreign_account_id_suffix] dup add.ACCT_ID_SUFFIX_OFFSET mem_load @@ -1760,7 +1763,7 @@ pub proc get_account_data_ptr # check that the loading of one more account won't exceed the maximum number of the foreign # accounts which can be loaded. - dup exec.memory::get_max_foreign_account_ptr lte + dup push.MAX_FOREIGN_ACCOUNT_PTR lte assert.err=ERR_FOREIGN_ACCOUNT_MAX_NUMBER_EXCEEDED # => [curr_account_ptr, foreign_account_id_prefix, foreign_account_id_suffix, is_equal_id] diff --git a/crates/miden-protocol/asm/kernels/transaction/lib/account_delta.masm b/crates/miden-protocol/asm/kernels/transaction/lib/account_delta.masm index 969438b4f5..6988c83a1c 100644 --- a/crates/miden-protocol/asm/kernels/transaction/lib/account_delta.masm +++ b/crates/miden-protocol/asm/kernels/transaction/lib/account_delta.masm @@ -4,6 +4,8 @@ use $kernel::asset_vault use $kernel::constants::STORAGE_SLOT_TYPE_VALUE use $kernel::link_map use $kernel::memory +use $kernel::memory::ACCOUNT_DELTA_FUNGIBLE_ASSET_PTR +use $kernel::memory::ACCOUNT_DELTA_NON_FUNGIBLE_ASSET_PTR use $kernel::util::asset::FUNGIBLE_ASSET_MAX_AMOUNT use miden::core::crypto::hashes::rpo256 use miden::core::word @@ -325,7 +327,7 @@ end #! Outputs: [RATE, RATE, PERM] @locals(2) proc update_fungible_asset_delta - exec.memory::get_account_delta_fungible_asset_ptr + push.ACCOUNT_DELTA_FUNGIBLE_ASSET_PTR # => [account_delta_fungible_asset_ptr, RATE, RATE, PERM] exec.link_map::iter @@ -406,7 +408,7 @@ end #! Outputs: [RATE, RATE, PERM] @locals(2) proc update_non_fungible_asset_delta - exec.memory::get_account_delta_non_fungible_asset_ptr + push.ACCOUNT_DELTA_NON_FUNGIBLE_ASSET_PTR # => [account_delta_non_fungible_asset_ptr, RATE, RATE, PERM] exec.link_map::iter @@ -561,7 +563,7 @@ end #! - ASSET_KEY is the asset key of the fungible asset. #! - amount is the amount by which the fungible asset's amount increases. pub proc add_fungible_asset - dupw exec.memory::get_account_delta_fungible_asset_ptr + dupw push.ACCOUNT_DELTA_FUNGIBLE_ASSET_PTR # => [fungible_delta_map_ptr, ASSET_KEY, ASSET_KEY, amount] # retrieve the current delta amount @@ -582,7 +584,7 @@ pub proc add_fungible_asset swapw padw movdnw.2 # => [ASSET_KEY, delta_amount, 0, 0, 0, EMPTY_WORD] - exec.memory::get_account_delta_fungible_asset_ptr + push.ACCOUNT_DELTA_FUNGIBLE_ASSET_PTR # => [fungible_delta_map_ptr, ASSET_KEY, delta_amount, 0, 0, 0, EMPTY_WORD] exec.link_map::set drop @@ -598,7 +600,7 @@ end #! - ASSET_KEY is the asset key of the fungible asset. #! - amount is the amount by which the fungible asset's amount decreases. pub proc remove_fungible_asset - dupw exec.memory::get_account_delta_fungible_asset_ptr + dupw push.ACCOUNT_DELTA_FUNGIBLE_ASSET_PTR # => [fungible_delta_map_ptr, ASSET_KEY, ASSET_KEY, amount] # retrieve the current delta amount @@ -619,7 +621,7 @@ pub proc remove_fungible_asset swapw padw movdnw.2 # => [ASSET_KEY, delta_amount, 0, 0, 0, EMPTY_WORD] - exec.memory::get_account_delta_fungible_asset_ptr + push.ACCOUNT_DELTA_FUNGIBLE_ASSET_PTR # => [fungible_delta_map_ptr, ASSET_KEY, delta_amount, 0, 0, 0, EMPTY_WORD] exec.link_map::set drop @@ -648,7 +650,7 @@ end #! Where: #! - ASSET is the non-fungible asset to be added. pub proc add_non_fungible_asset - dupw exec.memory::get_account_delta_non_fungible_asset_ptr + dupw push.ACCOUNT_DELTA_NON_FUNGIBLE_ASSET_PTR # => [non_fungible_delta_map_ptr, ASSET, ASSET] # retrieve the current delta @@ -663,7 +665,7 @@ pub proc add_non_fungible_asset movupw.2 # => [ASSET, was_added, 0, 0, 0, EMPTY_WORD] - exec.memory::get_account_delta_non_fungible_asset_ptr + push.ACCOUNT_DELTA_NON_FUNGIBLE_ASSET_PTR # => [non_fungible_delta_map_ptr, ASSET, was_added, 0, 0, 0, EMPTY_WORD] exec.link_map::set drop @@ -682,7 +684,7 @@ end #! Where: #! - ASSET is the non-fungible asset to be removed. pub proc remove_non_fungible_asset - dupw exec.memory::get_account_delta_non_fungible_asset_ptr + dupw push.ACCOUNT_DELTA_NON_FUNGIBLE_ASSET_PTR # => [non_fungible_delta_map_ptr, ASSET, ASSET] # retrieve the current delta @@ -697,7 +699,7 @@ pub proc remove_non_fungible_asset movupw.2 # => [ASSET, was_added, 0, 0, 0, EMPTY_WORD] - exec.memory::get_account_delta_non_fungible_asset_ptr + push.ACCOUNT_DELTA_NON_FUNGIBLE_ASSET_PTR # => [non_fungible_delta_map_ptr, ASSET, was_added, 0, 0, 0, EMPTY_WORD] exec.link_map::set drop diff --git a/crates/miden-protocol/asm/kernels/transaction/lib/epilogue.masm b/crates/miden-protocol/asm/kernels/transaction/lib/epilogue.masm index 63a8f92a61..ce899dfcc6 100644 --- a/crates/miden-protocol/asm/kernels/transaction/lib/epilogue.masm +++ b/crates/miden-protocol/asm/kernels/transaction/lib/epilogue.masm @@ -3,6 +3,8 @@ use $kernel::account_delta use $kernel::asset_vault use $kernel::constants::NOTE_MEM_SIZE use $kernel::memory +use $kernel::memory::OUTPUT_NOTE_SECTION_OFFSET +use $kernel::memory::OUTPUT_VAULT_ROOT_PTR use $kernel::note use miden::core::crypto::hashes::rpo256 @@ -89,7 +91,7 @@ proc copy_output_notes_to_advice_map # => [OUTPUT_NOTES_COMMITMENT, output_notes_end_ptr] # compute the start boundary of the output notes section - exec.memory::get_output_note_data_offset movdn.4 + push.OUTPUT_NOTE_SECTION_OFFSET movdn.4 # => [OUTPUT_NOTES_COMMITMENT, output_note_ptr, output_notes_end_ptr] # insert created data into the advice map @@ -146,7 +148,7 @@ proc build_output_vault # => [num_assets, note_data_ptr, output_notes_end_ptr] # prepare stack for reading output note assets - exec.memory::get_output_vault_root_ptr dup.2 exec.memory::get_output_note_asset_data_ptr dup + push.OUTPUT_VAULT_ROOT_PTR dup.2 exec.memory::get_output_note_asset_data_ptr dup # => [assets_start_ptr, assets_start_ptr, output_vault_root_ptr, num_assets, note_data_ptr, # output_notes_end_ptr] diff --git a/crates/miden-protocol/asm/kernels/transaction/lib/faucet.masm b/crates/miden-protocol/asm/kernels/transaction/lib/faucet.masm index b2aad39f10..8a116152a7 100644 --- a/crates/miden-protocol/asm/kernels/transaction/lib/faucet.masm +++ b/crates/miden-protocol/asm/kernels/transaction/lib/faucet.masm @@ -3,6 +3,7 @@ use $kernel::account_id use $kernel::asset use $kernel::asset_vault use $kernel::memory +use $kernel::memory::INPUT_VAULT_ROOT_PTR use $kernel::util::asset::FUNGIBLE_ASSET_MAX_AMOUNT # ERRORS @@ -34,7 +35,7 @@ pub proc mint_fungible_asset exec.asset::validate_fungible_asset_origin # => [ASSET] - exec.memory::get_input_vault_root_ptr + push.INPUT_VAULT_ROOT_PTR movdn.4 # => [ASSET, input_vault_root_ptr] @@ -64,7 +65,7 @@ proc burn_fungible_asset exec.asset::validate_fungible_asset_origin # => [ASSET] - exec.memory::get_input_vault_root_ptr + push.INPUT_VAULT_ROOT_PTR movdn.4 # => [ASSET, input_vault_root_ptr] @@ -99,7 +100,7 @@ proc mint_non_fungible_asset exec.asset::validate_non_fungible_asset_origin # => [ASSET] - exec.memory::get_input_vault_root_ptr + push.INPUT_VAULT_ROOT_PTR movdn.4 # => [ASSET, input_vault_root_ptr] @@ -132,7 +133,7 @@ proc burn_non_fungible_asset # => [ASSET] # remove the non-fungible asset from the input vault for asset preservation - exec.memory::get_input_vault_root_ptr + push.INPUT_VAULT_ROOT_PTR movdn.4 # => [ASSET, input_vault_root_ptr] diff --git a/crates/miden-protocol/asm/kernels/transaction/lib/link_map.masm b/crates/miden-protocol/asm/kernels/transaction/lib/link_map.masm index 3ed748cb27..cf34b6669c 100644 --- a/crates/miden-protocol/asm/kernels/transaction/lib/link_map.masm +++ b/crates/miden-protocol/asm/kernels/transaction/lib/link_map.masm @@ -1,6 +1,9 @@ use miden::core::collections::smt use miden::core::word use $kernel::memory +use $kernel::memory::LINK_MAP_ENTRY_SIZE +use $kernel::memory::LINK_MAP_REGION_END_PTR +use $kernel::memory::LINK_MAP_REGION_START_PTR # A link map is a map data structure based on a sorted linked list. # @@ -876,7 +879,7 @@ pub proc assert_entry_ptr_is_valid u32assert.err=ERR_LINK_MAP_ENTRY_PTR_IS_OUTSIDE_VALID_MEMORY_REGION # => [entry_ptr, map_ptr] - exec.memory::get_link_map_region_start_ptr dup.1 + push.LINK_MAP_REGION_START_PTR dup.1 # => [entry_ptr, region_start_ptr, entry_ptr, map_ptr] # compute region_start_ptr <= entry_ptr @@ -884,7 +887,7 @@ pub proc assert_entry_ptr_is_valid u32lte # => [is_entry_ptr_gt_start, entry_ptr, map_ptr] - dup.1 exec.memory::get_link_map_region_end_ptr + dup.1 push.LINK_MAP_REGION_END_PTR # => [region_end_ptr, entry_ptr, is_entry_ptr_gt_start, entry_ptr, map_ptr] # compute entry_ptr < region_end_ptr @@ -910,7 +913,7 @@ pub proc assert_entry_ptr_is_valid # any valid entry pointer is a multiple of LINK_MAP_ENTRY_SIZE. So to check validity, # we assert that entry_ptr % LINK_MAP_ENTRY_SIZE == 0. # note: we previously asserted that entry_ptr fits in a u32 - dup exec.memory::get_link_map_entry_size u32mod eq.0 + dup push.LINK_MAP_ENTRY_SIZE u32mod eq.0 # => [is_entry_ptr_aligned, entry_ptr, map_ptr, is_empty_map] # this assertion is always true if is_empty_map is true diff --git a/crates/miden-protocol/asm/kernels/transaction/lib/memory.masm b/crates/miden-protocol/asm/kernels/transaction/lib/memory.masm index 1053323ea1..3c437bda9a 100644 --- a/crates/miden-protocol/asm/kernels/transaction/lib/memory.masm +++ b/crates/miden-protocol/asm/kernels/transaction/lib/memory.masm @@ -352,18 +352,6 @@ pub proc set_active_input_note_ptr mem_store.ACTIVE_INPUT_NOTE_PTR end -#! Returns the pointer to the memory address at which the input vault root is stored. -#! -#! Inputs: [] -#! Outputs: [input_vault_root_ptr] -#! -#! Where: -#! - input_vault_root_ptr is a pointer to the memory address at which the input vault root is -#! stored. -pub proc get_input_vault_root_ptr - push.INPUT_VAULT_ROOT_PTR -end - #! Returns the input vault root. #! #! Inputs: [] @@ -386,18 +374,6 @@ pub proc set_input_vault_root mem_storew_be.INPUT_VAULT_ROOT_PTR end -#! Returns the pointer to the memory address at which the output vault root is stored. -#! -#! Inputs: [] -#! Outputs: [output_vault_root_ptr] -#! -#! Where: -#! - output_vault_root_ptr is the pointer to the memory address at which the output vault root is -#! stored. -pub proc get_output_vault_root_ptr - push.OUTPUT_VAULT_ROOT_PTR -end - #! Returns the output vault root. #! #! Inputs: [] @@ -642,17 +618,6 @@ pub proc set_nullifier_commitment mem_storew_be.INPUT_NOTES_COMMITMENT_PTR end -#! Returns the memory address of the transaction script root. -#! -#! Inputs: [] -#! Outputs: [tx_script_root_ptr] -#! -#! Where: -#! - tx_script_root_ptr is the pointer to the memory where transaction script root is stored. -pub proc get_tx_script_root_ptr - push.TX_SCRIPT_ROOT_PTR -end - #! Sets the transaction script root. #! #! Inputs: [TX_SCRIPT_ROOT] @@ -713,17 +678,6 @@ end # BLOCK DATA # ------------------------------------------------------------------------------------------------- -#! Returns a pointer to the block data section. -#! -#! Inputs: [] -#! Outputs: [ptr] -#! -#! Where: -#! - ptr is a pointer to the block data section. -pub proc get_block_data_ptr - push.BLOCK_DATA_SECTION_OFFSET -end - #! Returns the previous block commitment of the transaction reference block. #! #! Inputs: [] @@ -887,17 +841,6 @@ end # CHAIN DATA # ------------------------------------------------------------------------------------------------- -#! Returns a pointer to the partial blockchain section. -#! -#! Inputs: [] -#! Outputs: [ptr] -#! -#! Where: -#! - ptr is the pointer to the partial blockchain section. -pub proc get_partial_blockchain_ptr - push.PARTIAL_BLOCKCHAIN_PTR -end - #! Sets the number of leaves in the partial blockchain. #! #! Inputs: [num_leaves] @@ -909,54 +852,9 @@ pub proc set_partial_blockchain_num_leaves mem_store.PARTIAL_BLOCKCHAIN_NUM_LEAVES_PTR end -#! Returns a pointer to start of the partial blockchain peaks section. -#! -#! Inputs: [] -#! Outputs: [ptr] -#! -#! Where: -#! - ptr is the pointer to the start of the partial blockchain peaks section. -pub proc get_partial_blockchain_peaks_ptr - push.PARTIAL_BLOCKCHAIN_PEAKS_PTR -end - # ACCOUNT DATA # ------------------------------------------------------------------------------------------------- -#! Returns the memory pointer at which the native account data is stored. -#! -#! Inputs: [] -#! Outputs: [ptr] -#! -#! Where: -#! - ptr is the memory address at which the native account data is stored. -pub proc get_native_account_data_ptr - push.NATIVE_ACCOUNT_DATA_PTR -end - -#! Returns the length of the memory interval that the account data occupies. -#! -#! Inputs: [] -#! Outputs: [account_data_length] -#! -#! Where: -#! - account_data_length is the length of the memory interval that the account data occupies. -pub proc get_account_data_length - push.ACCOUNT_DATA_LENGTH -end - -#! Returns the largest memory address which can be used to load the foreign account data. -#! -#! Inputs: [] -#! Outputs: [max_foreign_account_ptr] -#! -#! Where: -#! - max_foreign_account_ptr is the largest memory address which can be used to load the foreign -#! account data. -pub proc get_max_foreign_account_ptr - push.MAX_FOREIGN_ACCOUNT_PTR -end - #! Sets the memory pointer of the active account data to the native account (8192). #! #! Inputs: [] @@ -1458,7 +1356,7 @@ end #! Where: #! - storage_slots_section_ptr is the memory pointer to the native account's storage slots section. pub proc get_native_account_active_storage_slots_ptr - exec.get_native_account_data_ptr add.ACCT_ACTIVE_STORAGE_SLOTS_SECTION_OFFSET + push.NATIVE_ACCOUNT_DATA_PTR add.ACCT_ACTIVE_STORAGE_SLOTS_SECTION_OFFSET end #! Returns the memory pointer to the initial storage slots of the native account. @@ -1469,7 +1367,7 @@ end #! Where: #! - account_initial_storage_slots_ptr is the memory pointer to the initial storage slot values. pub proc get_native_account_initial_storage_slots_ptr - exec.get_native_account_data_ptr add.ACCT_INITIAL_STORAGE_SLOTS_SECTION_OFFSET + push.NATIVE_ACCOUNT_DATA_PTR add.ACCT_INITIAL_STORAGE_SLOTS_SECTION_OFFSET end #! Returns the memory pointer to the initial storage slots of the active account. @@ -1504,28 +1402,6 @@ end ### ACCOUNT DELTA ################################################# -#! Returns the link map pointer to the fungible asset vault delta. -#! -#! Inputs: [] -#! Outputs: [account_delta_fungible_asset_ptr] -#! -#! Where: -#! - account_delta_fungible_asset_ptr is the link map pointer to the fungible asset vault delta. -pub proc get_account_delta_fungible_asset_ptr - push.ACCOUNT_DELTA_FUNGIBLE_ASSET_PTR -end - -#! Returns the link map pointer to the non-fungible asset vault delta. -#! -#! Inputs: [] -#! Outputs: [account_delta_non_fungible_asset_ptr] -#! -#! Where: -#! - account_delta_non_fungible_asset_ptr is the link map pointer to the non-fungible asset vault delta. -pub proc get_account_delta_non_fungible_asset_ptr - push.ACCOUNT_DELTA_NON_FUNGIBLE_ASSET_PTR -end - #! Returns the link map pointer to the storage map delta of the storage map in the given slot index. #! #! Inputs: [slot_idx] @@ -1887,17 +1763,6 @@ end # OUTPUT NOTES # ------------------------------------------------------------------------------------------------- -#! Returns the offset of the output note data segment. -#! -#! Inputs: [] -#! Outputs: [offset] -#! -#! Where: -#! - offset is the offset of the output note data segment. -pub proc get_output_note_data_offset - push.OUTPUT_NOTE_SECTION_OFFSET -end - #! Computes a pointer to the memory address at which the data associated with an output note with #! index `i` is stored. #! @@ -2138,45 +2003,9 @@ pub proc get_num_kernel_procedures mem_load.NUM_KERNEL_PROCEDURES_PTR end -#! Returns a pointer to the memory where hashes of the kernel procedures are stored. -#! -#! Inputs: [] -#! Outputs: [kernel_procedures_ptr] -#! -#! Where: -#! - kernel_procedures_ptr is the memory address where the hashes of the kernel procedures are -#! stored. -pub proc get_kernel_procedures_ptr - push.KERNEL_PROCEDURES_PTR -end - # LINK MAP # ------------------------------------------------------------------------------------------------- -#! Returns the link map memory start ptr constant. -#! -#! Inputs: [] -#! Outputs: [start_ptr] -pub proc get_link_map_region_start_ptr - push.LINK_MAP_REGION_START_PTR -end - -#! Returns the link map memory end ptr constant. -#! -#! Inputs: [] -#! Outputs: [end_ptr] -pub proc get_link_map_region_end_ptr - push.LINK_MAP_REGION_END_PTR -end - -#! Returns the link map entry size constant. -#! -#! Inputs: [] -#! Outputs: [entry_size] -pub proc get_link_map_entry_size - push.LINK_MAP_ENTRY_SIZE -end - #! Returns the next pointer to an empty link map entry. #! #! Inputs: [] diff --git a/crates/miden-protocol/asm/kernels/transaction/lib/prologue.masm b/crates/miden-protocol/asm/kernels/transaction/lib/prologue.masm index a565cd57a2..cb8a23d8e5 100644 --- a/crates/miden-protocol/asm/kernels/transaction/lib/prologue.masm +++ b/crates/miden-protocol/asm/kernels/transaction/lib/prologue.masm @@ -15,6 +15,10 @@ use $kernel::constants::NOTE_TREE_DEPTH use $kernel::constants::STORAGE_SLOT_TYPE_MAP use $kernel::constants::STORAGE_SLOT_TYPE_VALUE use $kernel::memory +use $kernel::memory::BLOCK_DATA_SECTION_OFFSET +use $kernel::memory::INPUT_VAULT_ROOT_PTR +use $kernel::memory::KERNEL_PROCEDURES_PTR +use $kernel::memory::PARTIAL_BLOCKCHAIN_PTR # CONSTS # ================================================================================================= @@ -135,7 +139,7 @@ proc process_kernel_data # AS => [[KERNEL_PROCEDURE_ROOTS]] # get the pointer to the memory where hashes of the kernel procedures will be stored - exec.memory::get_kernel_procedures_ptr swap + push.KERNEL_PROCEDURES_PTR swap # OS => [num_kernel_procedures, kernel_procs_ptr, TX_KERNEL_COMMITMENT] # AS => [[KERNEL_PROCEDURE_ROOTS]] @@ -196,7 +200,7 @@ end #! transaction. #! - NOTE_ROOT is the root of the tree with all notes created in the block. proc process_block_data - exec.memory::get_block_data_ptr + push.BLOCK_DATA_SECTION_OFFSET # => [block_data_ptr, block_num] # read block data and compute its sub commitment @@ -257,7 +261,7 @@ end #! - num_blocks is the number of blocks in the MMR. #! - PEAK_1 .. PEAK_N are the MMR peaks. proc process_chain_data - exec.memory::get_partial_blockchain_ptr dup + push.PARTIAL_BLOCKCHAIN_PTR dup # => [partial_blockchain_ptr, partial_blockchain_ptr] # save the MMR peaks to memory and verify it matches the block's CHAIN_COMMITMENT @@ -477,7 +481,7 @@ proc authenticate_note # Load the BLOCK_COMMITMENT from the PARTIAL_BLOCKCHAIN # --------------------------------------------------------------------------------------------- - exec.memory::get_partial_blockchain_ptr adv_push.1 + push.PARTIAL_BLOCKCHAIN_PTR adv_push.1 # => [block_num, partial_blockchain_ptr, NOTE_COMMITMENT] exec.mmr::get @@ -719,7 +723,7 @@ proc add_input_note_assets_to_vault # prepare the stack # --------------------------------------------------------------------------------------------- - exec.memory::get_input_vault_root_ptr + push.INPUT_VAULT_ROOT_PTR # => [input_vault_root_ptr, note_ptr] dup.1 exec.memory::get_input_note_assets_ptr diff --git a/crates/miden-protocol/asm/kernels/transaction/main.masm b/crates/miden-protocol/asm/kernels/transaction/main.masm index fe0c0d0383..24b9a578fc 100644 --- a/crates/miden-protocol/asm/kernels/transaction/main.masm +++ b/crates/miden-protocol/asm/kernels/transaction/main.masm @@ -2,6 +2,7 @@ use miden::core::word use $kernel::epilogue use $kernel::memory +use $kernel::memory::TX_SCRIPT_ROOT_PTR use $kernel::note use $kernel::prologue @@ -129,7 +130,7 @@ proc main emit.TX_SCRIPT_PROCESSING_START_EVENT # get the memory address of the transaction script root and load it to the stack - exec.memory::get_tx_script_root_ptr + push.TX_SCRIPT_ROOT_PTR padw dup.4 mem_loadw_be # => [TX_SCRIPT_ROOT, tx_script_root_ptr, pad(16)] diff --git a/crates/miden-protocol/asm/kernels/transaction/tx_script_main.masm b/crates/miden-protocol/asm/kernels/transaction/tx_script_main.masm index b0b12ea8cf..99f16897d1 100644 --- a/crates/miden-protocol/asm/kernels/transaction/tx_script_main.masm +++ b/crates/miden-protocol/asm/kernels/transaction/tx_script_main.masm @@ -1,6 +1,7 @@ use miden::core::word use $kernel::memory +use $kernel::memory::TX_SCRIPT_ROOT_PTR use $kernel::prologue # ERRORS @@ -45,7 +46,7 @@ proc main # --------------------------------------------------------------------------------------------- # get the memory address of the transaction script root and load it to the stack - exec.memory::get_tx_script_root_ptr + push.TX_SCRIPT_ROOT_PTR padw dup.4 mem_loadw_be # => [TX_SCRIPT_ROOT, tx_script_root_ptr]