From 4d5c896f659a99e93430b8fff2e63c4e193d36ad Mon Sep 17 00:00:00 2001 From: Andrey Khmuro Date: Thu, 26 Dec 2024 16:49:28 +0300 Subject: [PATCH] refactor: initial kernel procs renaming and reordering --- miden-lib/asm/miden/kernel_proc_offsets.masm | 397 +++++++++++-------- 1 file changed, 221 insertions(+), 176 deletions(-) diff --git a/miden-lib/asm/miden/kernel_proc_offsets.masm b/miden-lib/asm/miden/kernel_proc_offsets.masm index 3add74530..9417d9009 100644 --- a/miden-lib/asm/miden/kernel_proc_offsets.masm +++ b/miden-lib/asm/miden/kernel_proc_offsets.masm @@ -1,96 +1,132 @@ # OFFSET CONSTANTS # ------------------------------------------------------------------------------------------------- -# Current account -const.ACCOUNT_VAULT_ADD_ASSET_OFFSET=0 -const.ACCOUNT_VAULT_GET_BALANCE_OFFSET=1 -const.ACCOUNT_VAULT_HAS_NON_FUNGIBLE_ASSET_OFFSET=2 -const.ACCOUNT_VAULT_REMOVE_ASSET_OFFSET=3 -const.GET_ACCOUNT_ID_OFFSET=4 -const.GET_ACCOUNT_ITEM_OFFSET=5 -const.GET_ACCOUNT_MAP_ITEM_OFFSET=6 -const.GET_ACCOUNT_NONCE_OFFSET=7 -const.GET_ACCOUNT_VAULT_COMMITMENT_OFFSET=8 -const.GET_CURRENT_ACCOUNT_HASH_OFFSET=9 -const.GET_INITIAL_ACCOUNT_HASH_OFFSET=10 -const.INCR_ACCOUNT_NONCE_OFFSET=11 -const.SET_ACCOUNT_CODE_OFFSET=12 -const.SET_ACCOUNT_ITEM_OFFSET=13 -const.SET_ACCOUNT_MAP_ITEM_OFFSET=14 - -# Current faucet -const.BURN_ASSET_OFFSET=15 -const.GET_FUNGIBLE_FAUCET_TOTAL_ISSUANCE_OFFSET=16 -const.MINT_ASSET_OFFSET=17 - -# Current note -const.ADD_ASSET_TO_NOTE_OFFSET=18 -const.CREATE_NOTE_OFFSET=19 -const.GET_INPUT_NOTES_COMMITMENT_OFFSET=20 -const.GET_NOTE_ASSETS_INFO_OFFSET=21 -const.GET_NOTE_INPUTS_HASH_OFFSET=22 -const.GET_NOTE_SENDER_OFFSET=23 -const.GET_NOTE_SERIAL_NUMBER_OFFSET=24 -const.GET_SCRIPT_HASH_OFFSET=25 -const.GET_OUTPUT_NOTES_COMMITMENT_OFFSET=26 - -# Transaction -const.GET_BLOCK_HASH_OFFSET=27 -const.GET_BLOCK_NUMBER_OFFSET=28 -const.START_FOREIGN_CONTEXT_OFFSET=29 -const.END_FOREIGN_CONTEXT_OFFSET=30 -const.UPDATE_EXPIRATION_BLOCK_NUM_OFFSET=31 -const.GET_EXPIRATION_DELTA_OFFSET=32 +### Account ##################################### +# Entire account hash +const.ACCOUNT_GET_CURRENT_HASH_OFFSET=0 +const.ACCOUNT_GET_INITIAL_HASH_OFFSET=1 + +# ID +const.ACCOUNT_GET_ID_OFFSET=2 + +# Nonce +const.ACCOUNT_GET_NONCE_OFFSET=3 # accessor +const.ACCOUNT_INCR_NONCE_OFFSET=4 # mutator + +# Procedures +## get account code is missing +const.ACCOUNT_PROCEDURES_SET_CODE_OFFSET=5 + +# Storage +const.ACCOUNT_STORAGE_GET_ITEM_OFFSET=6 +const.ACCOUNT_STORAGE_SET_ITEM_OFFSET=7 +const.ACCOUNT_STORAGE_GET_MAP_ITEM_OFFSET=8 +const.ACCOUNT_STORAGE_SET_MAP_ITEM_OFFSET=9 + +# Vault +const.ACCOUNT_VAULT_ADD_ASSET_OFFSET=10 +const.ACCOUNT_VAULT_REMOVE_ASSET_OFFSET=11 +const.ACCOUNT_VAULT_GET_BALANCE_OFFSET=12 +const.ACCOUNT_VAULT_HAS_NON_FUNGIBLE_ASSET_OFFSET=13 + +## set commitment is missing, but corresponding memory procedure is used in the +## start_foreign_context kernel procedure +const.ACCOUNT_VAULT_GET_COMMITMENT_OFFSET=14 + + +### Faucet ###################################### +const.FAUCET_BURN_ASSET_OFFSET=15 +const.FAUCET_FUNGIBLE_GET_TOTAL_ISSUANCE_OFFSET=16 + +# add a new procedure to the kernel +# const.FAUCET_NON_FUNGIBLE_IS_ISSUED_OFFSET=17 +const.FAUCET_MINT_ASSET_OFFSET=18 + + +### Note ######################################## +# creation +const.NOTE_CREATION_OFFSET=19 + +# io commitments +const.NOTE_GET_INPUT_NOTES_COMMITMENT_OFFSET=20 +const.NOTE_GET_OUTPUT_NOTES_COMMITMENT_OFFSET=21 + +# assets +const.NOTE_ADD_ASSET_OFFSET=22 # mutator +const.NOTE_GET_ASSETS_INFO_OFFSET=23 # accessor + +# note parameters +const.NOTE_GET_SERIAL_NUMBER_OFFSET=24 +const.NOTE_GET_INPUTS_HASH_OFFSET=25 +const.NOTE_GET_SENDER_OFFSET=26 +const.NOTE_GET_SCRIPT_HASH_OFFSET=27 + + +### Tx ########################################## +# block info +const.TX_GET_BLOCK_HASH_OFFSET=28 +const.TX_GET_BLOCK_NUMBER_OFFSET=29 + +# foreign context +const.TX_START_FOREIGN_CONTEXT_OFFSET=30 +const.TX_END_FOREIGN_CONTEXT_OFFSET=31 + +# expiration data +const.TX_UPDATE_EXPIRATION_BLOCK_NUM_OFFSET=32 # mutator +const.TX_GET_EXPIRATION_DELTA_OFFSET=33 # accessor + # ACCESSORS # ------------------------------------------------------------------------------------------------- -#! Returns an offset of the `get_account_id` kernel procedure. +### ACCOUNT ##################################### + +#! Returns an offset of the `get_current_account_hash` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_account_id` kernel procedure required to get the address -#! where this procedure is stored. -export.get_account_id_offset - push.GET_ACCOUNT_ID_OFFSET +#! - proc_offset is the offset of the `get_current_account_hash` kernel procedure required to get +#! the address where this procedure is stored. +export.get_current_account_hash_offset + push.ACCOUNT_GET_CURRENT_HASH_OFFSET end -#! Returns an offset of the `get_account_nonce` kernel procedure. +#! Returns an offset of the `get_initial_account_hash` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_account_nonce` kernel procedure required to get the -#! address where this procedure is stored. -export.get_account_nonce_offset - push.GET_ACCOUNT_NONCE_OFFSET +#! - proc_offset is the offset of the `get_initial_account_hash` kernel procedure required to get +#! the address where this procedure is stored. +export.get_initial_account_hash_offset + push.ACCOUNT_GET_INITIAL_HASH_OFFSET end -#! Returns an offset of the `get_initial_account_hash` kernel procedure. +#! Returns an offset of the `get_account_id` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_initial_account_hash` kernel procedure required to get -#! the address where this procedure is stored. -export.get_initial_account_hash_offset - push.GET_INITIAL_ACCOUNT_HASH_OFFSET +#! - proc_offset is the offset of the `get_account_id` kernel procedure required to get the address +#! where this procedure is stored. +export.get_account_id_offset + push.ACCOUNT_GET_ID_OFFSET end -#! Returns an offset of the `get_current_account_hash` kernel procedure. +#! Returns an offset of the `get_account_nonce` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_current_account_hash` kernel procedure required to get -#! the address where this procedure is stored. -export.get_current_account_hash_offset - push.GET_CURRENT_ACCOUNT_HASH_OFFSET +#! - proc_offset is the offset of the `get_account_nonce` kernel procedure required to get the +#! address where this procedure is stored. +export.get_account_nonce_offset + push.ACCOUNT_GET_NONCE_OFFSET end #! Returns an offset of the `incr_account_nonce` kernel procedure. @@ -102,7 +138,19 @@ end #! - proc_offset is the offset of the `incr_account_nonce` kernel procedure required to get the #! address where this procedure is stored. export.incr_account_nonce_offset - push.INCR_ACCOUNT_NONCE_OFFSET + push.ACCOUNT_INCR_NONCE_OFFSET +end + +#! Returns an offset of the `set_account_code` kernel procedure. +#! +#! Inputs: [] +#! Outputs: [proc_offset] +#! +#! Where: +#! - proc_offset is the offset of the `set_account_code` kernel procedure required to get the +#! address where this procedure is stored. +export.set_account_code_offset + push.ACCOUNT_PROCEDURES_SET_CODE_OFFSET end #! Returns an offset of the `get_account_item` kernel procedure. @@ -114,7 +162,7 @@ end #! - proc_offset is the offset of the `get_account_item` kernel procedure required to get the #! address where this procedure is stored. export.get_account_item_offset - push.GET_ACCOUNT_ITEM_OFFSET + push.ACCOUNT_STORAGE_GET_ITEM_OFFSET end #! Returns an offset of the `set_account_item` kernel procedure. @@ -126,7 +174,7 @@ end #! - proc_offset is the offset of the `set_account_item` kernel procedure required to get the #! address where this procedure is stored. export.set_account_item_offset - push.SET_ACCOUNT_ITEM_OFFSET + push.ACCOUNT_STORAGE_SET_ITEM_OFFSET end #! Returns an offset of the `get_account_map_item` kernel procedure. @@ -138,7 +186,7 @@ end #! - proc_offset is the offset of the `get_account_map_item` kernel procedure required to get the #! address where this procedure is stored. export.get_account_map_item_offset - push.GET_ACCOUNT_MAP_ITEM_OFFSET + push.ACCOUNT_STORAGE_GET_MAP_ITEM_OFFSET end #! Returns an offset of the `set_account_map_item` kernel procedure. @@ -150,43 +198,7 @@ end #! - proc_offset is the offset of the `set_account_map_item` kernel procedure required to get the #! address where this procedure is stored. export.set_account_map_item_offset - push.SET_ACCOUNT_MAP_ITEM_OFFSET -end - -#! Returns an offset of the `set_account_code` kernel procedure. -#! -#! Inputs: [] -#! Outputs: [proc_offset] -#! -#! Where: -#! - proc_offset is the offset of the `set_account_code` kernel procedure required to get the -#! address where this procedure is stored. -export.set_account_code_offset - push.SET_ACCOUNT_CODE_OFFSET -end - -#! Returns an offset of the `account_vault_get_balance` kernel procedure. -#! -#! Inputs: [] -#! Outputs: [proc_offset] -#! -#! Where: -#! - proc_offset is the offset of the `account_vault_get_balance` kernel procedure required to get -#! the address where this procedure is stored. -export.account_vault_get_balance_offset - push.ACCOUNT_VAULT_GET_BALANCE_OFFSET -end - -#! Returns an offset of the `account_vault_has_non_fungible_asset` kernel procedure. -#! -#! Inputs: [] -#! Outputs: [proc_offset] -#! -#! Where: -#! - proc_offset is the offset of the `account_vault_has_non_fungible_asset` kernel procedure -#! required to get the address where this procedure is stored. -export.account_vault_has_non_fungible_asset_offset - push.ACCOUNT_VAULT_HAS_NON_FUNGIBLE_ASSET_OFFSET + push.ACCOUNT_STORAGE_SET_MAP_ITEM_OFFSET end #! Returns an offset of the `account_vault_add_asset` kernel procedure. @@ -213,88 +225,94 @@ export.account_vault_remove_asset_offset push.ACCOUNT_VAULT_REMOVE_ASSET_OFFSET end -#! Returns an offset of the `get_note_assets_info` kernel procedure. +#! Returns an offset of the `account_vault_get_balance` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_note_assets_info` kernel procedure required to get the -#! address where this procedure is stored. -export.get_note_assets_info_offset - push.GET_NOTE_ASSETS_INFO_OFFSET +#! - proc_offset is the offset of the `account_vault_get_balance` kernel procedure required to get +#! the address where this procedure is stored. +export.account_vault_get_balance_offset + push.ACCOUNT_VAULT_GET_BALANCE_OFFSET end -#! Returns an offset of the `get_note_inputs_hash` kernel procedure. +#! Returns an offset of the `account_vault_has_non_fungible_asset` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_note_inputs_hash` kernel procedure required to get the -#! address where this procedure is stored. -export.get_note_inputs_hash_offset - push.GET_NOTE_INPUTS_HASH_OFFSET +#! - proc_offset is the offset of the `account_vault_has_non_fungible_asset` kernel procedure +#! required to get the address where this procedure is stored. +export.account_vault_has_non_fungible_asset_offset + push.ACCOUNT_VAULT_HAS_NON_FUNGIBLE_ASSET_OFFSET end -#! Returns an offset of the `get_note_sender` kernel procedure. +#! Returns an offset of the `get_account_vault_commitment` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_note_sender` kernel procedure required to get the address -#! where this procedure is stored. -export.get_note_sender_offset - push.GET_NOTE_SENDER_OFFSET +#! - proc_offset is the offset of the `get_account_vault_commitment` kernel procedure required to +#! get the address where this procedure is stored. +export.get_account_vault_commitment_offset + push.ACCOUNT_VAULT_GET_COMMITMENT_OFFSET end -#! Returns an offset of the `get_block_number` kernel procedure. + +### FAUCET ###################################### + +#! Returns an offset of the `burn_asset` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_block_number` kernel procedure required to get the -#! address where this procedure is stored. -export.get_block_number_offset - push.GET_BLOCK_NUMBER_OFFSET +#! - proc_offset is the offset of the `burn_asset` kernel procedure required to get the address +#! where this procedure is stored. +export.burn_asset_offset + push.FAUCET_BURN_ASSET_OFFSET end -#! Returns an offset of the `update_expiration_block_num` kernel procedure. +#! Returns an offset of the `get_fungible_faucet_total_issuance` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `set_tx_expiration_delta` kernel procedure required to get the -#! address where this procedure is stored. -export.update_expiration_block_num_offset - push.UPDATE_EXPIRATION_BLOCK_NUM_OFFSET +#! - proc_offset is the offset of the `get_fungible_faucet_total_issuance` kernel procedure required +#! to get the address where this procedure is stored. +export.get_fungible_faucet_total_issuance_offset + push.FAUCET_FUNGIBLE_GET_TOTAL_ISSUANCE_OFFSET end -#! Returns an offset of the `get_expiration_delta` kernel procedure. +#! Returns an offset of the `mint_asset` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `set_tx_expiration_delta` kernel procedure required to get the -#! address where this procedure is stored. -export.get_expiration_block_delta_offset - push.GET_EXPIRATION_DELTA_OFFSET +#! - proc_offset is the offset of the `mint_asset` kernel procedure required to get the address +#! where this procedure is stored. +export.mint_asset_offset + push.FAUCET_MINT_ASSET_OFFSET end -#! Returns an offset of the `get_block_hash` kernel procedure. + +### NOTE ######################################## + +#! Returns an offset of the `create_note` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_block_hash` kernel procedure required to get the address +#! - proc_offset is the offset of the `create_note` kernel procedure required to get the address #! where this procedure is stored. -export.get_block_hash_offset - push.GET_BLOCK_HASH_OFFSET +export.create_note_offset + push.NOTE_CREATION_OFFSET end #! Returns an offset of the `get_input_notes_commitment` kernel procedure. @@ -306,7 +324,7 @@ end #! - proc_offset is the offset of the `get_input_notes_commitment` kernel procedure required to get #! the address where this procedure is stored. export.get_input_notes_commitment_offset - push.GET_INPUT_NOTES_COMMITMENT_OFFSET + push.NOTE_GET_INPUT_NOTES_COMMITMENT_OFFSET end #! Returns an offset of the `get_output_notes_commitment` kernel procedure. @@ -318,103 +336,106 @@ end #! - proc_offset is the offset of the `get_output_notes_commitment` kernel procedure required to get #! the address where this procedure is stored. export.get_output_notes_commitment_offset - push.GET_OUTPUT_NOTES_COMMITMENT_OFFSET + push.NOTE_GET_OUTPUT_NOTES_COMMITMENT_OFFSET end -#! Returns an offset of the `create_note` kernel procedure. +#! Returns an offset of the `add_asset_to_note` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `create_note` kernel procedure required to get the address -#! where this procedure is stored. -export.create_note_offset - push.CREATE_NOTE_OFFSET +#! - proc_offset is the offset of the `add_asset_to_note` kernel procedure required to get the +#! address where this procedure is stored. +export.add_asset_to_note_offset + push.NOTE_ADD_ASSET_OFFSET end -#! Returns an offset of the `add_asset_to_note` kernel procedure. +#! Returns an offset of the `get_note_assets_info` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `add_asset_to_note` kernel procedure required to get the +#! - proc_offset is the offset of the `get_note_assets_info` kernel procedure required to get the #! address where this procedure is stored. -export.add_asset_to_note_offset - push.ADD_ASSET_TO_NOTE_OFFSET +export.get_note_assets_info_offset + push.NOTE_GET_ASSETS_INFO_OFFSET end -#! Returns an offset of the `get_account_vault_commitment` kernel procedure. +#! Returns an offset of the `get_note_serial_number` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_account_vault_commitment` kernel procedure required to -#! get the address where this procedure is stored. -export.get_account_vault_commitment_offset - push.GET_ACCOUNT_VAULT_COMMITMENT_OFFSET +#! - proc_offset is the offset of the `get_note_serial_number` kernel procedure required to get the +#! address where this procedure is stored. +export.get_note_serial_number_offset + push.NOTE_GET_SERIAL_NUMBER_OFFSET end -#! Returns an offset of the `mint_asset` kernel procedure. +#! Returns an offset of the `get_note_inputs_hash` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `mint_asset` kernel procedure required to get the address -#! where this procedure is stored. -export.mint_asset_offset - push.MINT_ASSET_OFFSET +#! - proc_offset is the offset of the `get_note_inputs_hash` kernel procedure required to get the +#! address where this procedure is stored. +export.get_note_inputs_hash_offset + push.NOTE_GET_INPUTS_HASH_OFFSET end -#! Returns an offset of the `burn_asset` kernel procedure. +#! Returns an offset of the `get_note_sender` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `burn_asset` kernel procedure required to get the address +#! - proc_offset is the offset of the `get_note_sender` kernel procedure required to get the address #! where this procedure is stored. -export.burn_asset_offset - push.BURN_ASSET_OFFSET +export.get_note_sender_offset + push.NOTE_GET_SENDER_OFFSET end -#! Returns an offset of the `get_fungible_faucet_total_issuance` kernel procedure. +#! Returns an offset of the `get_script_hash` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_fungible_faucet_total_issuance` kernel procedure required -#! to get the address where this procedure is stored. -export.get_fungible_faucet_total_issuance_offset - push.GET_FUNGIBLE_FAUCET_TOTAL_ISSUANCE_OFFSET +#! - proc_offset is the offset of the `get_script_hash` kernel procedure required to get the +#! address where this procedure is stored. +export.get_script_hash_offset + push.NOTE_GET_SCRIPT_HASH_OFFSET end -#! Returns an offset of the `get_note_serial_number` kernel procedure. + +### TRANSACTION ################################# + +#! Returns an offset of the `get_block_hash` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_note_serial_number` kernel procedure required to get the -#! address where this procedure is stored. -export.get_note_serial_number_offset - push.GET_NOTE_SERIAL_NUMBER_OFFSET +#! - proc_offset is the offset of the `get_block_hash` kernel procedure required to get the address +#! where this procedure is stored. +export.get_block_hash_offset + push.TX_GET_BLOCK_HASH_OFFSET end -#! Returns an offset of the `get_script_hash` kernel procedure. +#! Returns an offset of the `get_block_number` kernel procedure. #! #! Inputs: [] #! Outputs: [proc_offset] #! #! Where: -#! - proc_offset is the offset of the `get_script_hash` kernel procedure required to get the +#! - proc_offset is the offset of the `get_block_number` kernel procedure required to get the #! address where this procedure is stored. -export.get_script_hash_offset - push.GET_SCRIPT_HASH_OFFSET +export.get_block_number_offset + push.TX_GET_BLOCK_NUMBER_OFFSET end #! Returns an offset of the `start_foreign_context` kernel procedure. @@ -426,7 +447,7 @@ end #! - proc_offset is the offset of the `start_foreign_context` kernel procedure required to get the #! address where this procedure is stored. export.start_foreign_context_offset - push.START_FOREIGN_CONTEXT_OFFSET + push.TX_START_FOREIGN_CONTEXT_OFFSET end #! Returns an offset of the `end_foreign_context` kernel procedure. @@ -438,5 +459,29 @@ end #! - proc_offset is the offset of the `end_foreign_context` kernel procedure required to get the #! address where this procedure is stored. export.end_foreign_context_offset - push.END_FOREIGN_CONTEXT_OFFSET + push.TX_END_FOREIGN_CONTEXT_OFFSET +end + +#! Returns an offset of the `update_expiration_block_num` kernel procedure. +#! +#! Inputs: [] +#! Outputs: [proc_offset] +#! +#! Where: +#! - proc_offset is the offset of the `set_tx_expiration_delta` kernel procedure required to get the +#! address where this procedure is stored. +export.update_expiration_block_num_offset + push.TX_UPDATE_EXPIRATION_BLOCK_NUM_OFFSET +end + +#! Returns an offset of the `get_expiration_delta` kernel procedure. +#! +#! Inputs: [] +#! Outputs: [proc_offset] +#! +#! Where: +#! - proc_offset is the offset of the `set_tx_expiration_delta` kernel procedure required to get the +#! address where this procedure is stored. +export.get_expiration_block_delta_offset + push.TX_GET_EXPIRATION_DELTA_OFFSET end