Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/miden-protocol/asm/kernels/transaction/api.masm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1534,7 +1535,7 @@ pub proc exec_kernel_proc
# => [procedure_offset, <procedure_inputs>, <pad>]

# 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, <procedure_inputs>, <pad>]

# execute loaded procedure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]

Expand Down
9 changes: 5 additions & 4 deletions crates/miden-protocol/asm/kernels/transaction/lib/faucet.masm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down Expand Up @@ -876,15 +879,15 @@ 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
# region_start_ptr is guaranteed to be a u32
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
Expand All @@ -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
Expand Down
Loading