From 814e47057ef379a6e0b8ce329b0abf5a988de625 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 28 Aug 2024 20:45:33 +0300 Subject: [PATCH] refactor: rework procs invocation --- CHANGELOG.md | 6 + docs/architecture/transactions/contexts.md | 2 +- miden-lib/asm/kernels/transaction/api.masm | 169 ++++++-- .../asm/kernels/transaction/lib/memory.masm | 380 +----------------- .../asm/kernels/transaction/lib/prologue.masm | 5 +- miden-lib/asm/miden/account.masm | 211 ++++++++-- miden-lib/asm/miden/faucet.masm | 41 +- miden-lib/asm/miden/kernel_invocation.masm | 375 +++++++++++++++++ miden-lib/asm/miden/note.masm | 55 ++- miden-lib/asm/miden/tx.masm | 74 +++- miden-lib/src/transaction/mod.rs | 10 +- .../src/tests/kernel_tests/test_prologue.rs | 2 +- miden-tx/src/verifier/mod.rs | 4 +- objects/src/testing/account_code.rs | 20 +- 14 files changed, 842 insertions(+), 512 deletions(-) create mode 100644 miden-lib/asm/miden/kernel_invocation.masm diff --git a/CHANGELOG.md b/CHANGELOG.md index 62f9b192f..c5ad6e2c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.6.0 () + +### Changes + +- [BREAKING] Kernel procedures now have to be invoked using `dynexec` instruction (#803). + ## 0.5.0 (2024-08-27) ### Features diff --git a/docs/architecture/transactions/contexts.md b/docs/architecture/transactions/contexts.md index c37804da3..8ea1cbd89 100644 --- a/docs/architecture/transactions/contexts.md +++ b/docs/architecture/transactions/contexts.md @@ -70,7 +70,7 @@ The [account API](https://github.com/0xPolygonMiden/miden-base/blob/main/miden-l #! Add the specified asset to the vault. #! ... export.add_asset - exec.mem::account_vault_add_asset_ptr + exec.kernel_invocation::account_vault_add_asset_offset syscall.exec_kernel_proc end ``` diff --git a/miden-lib/asm/kernels/transaction/api.masm b/miden-lib/asm/kernels/transaction/api.masm index bac11641e..88b374e0f 100644 --- a/miden-lib/asm/kernels/transaction/api.masm +++ b/miden-lib/asm/kernels/transaction/api.masm @@ -1,4 +1,5 @@ use.std::collections::smt +use.std::sys use.kernel::account use.kernel::asset_vault @@ -10,9 +11,11 @@ use.kernel::tx # NOTE # ================================================================================================= -# Procedures in this module are expected to be invoked using a `syscall` instruction. It makes no # -# guarantees about the contents of the `PAD` elements shown in the inputs and outputs. It is the # -# caller's responsibility to make sure these elements do not contain any meaningful data. # +# `exec_kernel_proc` procedure is expected to be invoked using a `syscall` instruction. It makes # +# no guarantees about the contents of the `PAD` elements shown in the inputs and outputs. It is # +# the caller's responsibility to make sure these elements do not contain any meaningful data. # +# All other procedures must be invoked only using a `dynexec` instruction by their hashes stored # +# in the memory. # # ================================================================================================= # ERRORS @@ -70,11 +73,14 @@ end #! Returns the account id. #! -#! Stack: [0] +#! Stack: [KERNEL_PROCEDURE_HASH, 0] #! Output: [acct_id] #! #! - acct_id is the account id. export.get_account_id + # drop the procedure's hash + dropw + # get the account id exec.account::get_id # => [acct_id, 0] @@ -85,11 +91,14 @@ end #! Returns the account nonce. #! -#! Stack: [0] +#! Stack: [KERNEL_PROCEDURE_HASH, 0] #! Output: [nonce] #! #! - nonce is the account nonce. export.get_account_nonce + # drop the procedure's hash + dropw + # get the account nonce exec.account::get_nonce # => [0, nonce] @@ -100,11 +109,14 @@ end #! Returns the initial account hash. #! -#! Stack: [0, 0, 0, 0] +#! Stack: [KERNEL_PROCEDURE_HASH, 0, 0, 0, 0] #! Output: [H] #! #! - H is the initial account hash. export.get_initial_account_hash + # drop the procedure's hash + dropw + # get the initial account hash exec.account::get_initial_hash # => [H, 0, 0, 0, 0] @@ -115,11 +127,14 @@ end #! Computes and returns the account hash from account data stored in memory. #! -#! Stack: [0, 0, 0, 0] +#! Stack: [KERNEL_PROCEDURE_HASH, 0, 0, 0, 0] #! Output: [ACCT_HASH] #! #! - ACCT_HASH is the hash of the account data. export.get_current_account_hash + # drop the procedure's hash + dropw + # get the current account hash exec.account::get_current_hash # => [ACCT_HASH, 0, 0, 0, 0] @@ -130,12 +145,15 @@ end #! Increments the account nonce by the provided value. #! -#! Stack: [value] +#! Stack: [KERNEL_PROCEDURE_HASH, value] #! Output: [0] #! #! - value is the value to increment the nonce by. value can be at most 2^32 - 1 otherwise this #! procedure panics. export.incr_account_nonce + # drop the procedure's hash + dropw + # authenticate that the procedure invocation originates from the account context exec.authenticate_account_origin # => [value] @@ -151,12 +169,15 @@ end #! Gets an item from the account storage. Panics if the index is out of bounds. #! -#! Stack: [index, 0, 0, 0] +#! Stack: [KERNEL_PROCEDURE_HASH, index, 0, 0, 0] #! Output: [VALUE] #! #! - index is the index of the item to get. #! - VALUE is the value of the item. export.get_account_item + # drop the procedure's hash + dropw + # fetch the account storage item exec.account::get_item # => [VALUE, 0, 0, 0] @@ -168,7 +189,7 @@ end #! Sets an item in the account storage. Panics if the index is out of bounds. #! -#! Stack: [index, V', 0, 0, 0] +#! Stack: [KERNEL_PROCEDURE_HASH, index, V', 0, 0, 0] #! Output: [R', V] #! #! - index is the index of the item to set. @@ -176,6 +197,9 @@ end #! - V is the previous value of the item. #! - R' is the new storage root. export.set_account_item + # drop the procedure's hash + dropw + # if the transaction is being executed against a faucet account then assert # index != FAUCET_STORAGE_DATA_SLOT (reserved slot) dup exec.account::get_faucet_storage_data_slot eq @@ -201,12 +225,15 @@ end #! - the index is out of bounds (>255). #! - the requested storage slot type is not map #! -#! Stack: [index, KEY, ...] +#! Stack: [KERNEL_PROCEDURE_HASH, index, KEY, ...] #! Output: [VALUE, 0] #! #! - index is the index of the item to get. #! - VALUE is the value of the item. export.get_account_map_item + # drop the procedure's hash + dropw + # check if storage type is map dup exec.account::get_storage_slot_type_info drop # => [slot_type, index, KEY, ...] @@ -234,7 +261,7 @@ end #! - the requested storage slot type is not map #! - the procedure is called from a non-account context #! -#! Stack: [index, KEY, NEW_VALUE, ...] +#! Stack: [KERNEL_PROCEDURE_HASH, index, KEY, NEW_VALUE, ...] #! Output: [OLD_MAP_ROOT, OLD_MAP_VALUE, 0] #! #! - index is the index of the item to get. @@ -244,6 +271,9 @@ end #! - OLD_MAP_ROOT is the root of the old map before insertion #! - NEW_MAP_ROOT is the root of the new map after insertion. export.set_account_map_item.1 + # drop the procedure's hash + dropw + # authenticate that the procedure invocation originates from the account context exec.authenticate_account_origin # => [index, KEY, NEW_VALUE, ...] @@ -268,11 +298,14 @@ end #! Sets the code of the account the transaction is being executed against. This procedure can only #! executed on regular accounts with updatable code. Otherwise, this procedure fails. #! -#! Stack: [CODE_COMMITMENT] +#! Stack: [KERNEL_PROCEDURE_HASH, CODE_COMMITMENT] #! Output: [0, 0, 0, 0] #! #! - CODE_COMMITMENT is the hash of the code to set. export.set_account_code + # drop the procedure's hash + dropw + # authenticate that the procedure invocation originates from the account context exec.authenticate_account_origin # => [CODE_COMMITMENT] @@ -289,12 +322,15 @@ end #! Returns the balance of a fungible asset associated with a faucet_id. #! Panics if the asset is not a fungible asset. #! -#! Stack: [faucet_id] +#! Stack: [KERNEL_PROCEDURE_HASH, faucet_id] #! Output: [balance] #! #! - faucet_id is the faucet id of the fungible asset of interest. #! - balance is the vault balance of the fungible asset. export.account_vault_get_balance + # drop the procedure's hash + dropw + # get the vault root exec.memory::get_acct_vault_root_ptr swap # => [faucet_id, acct_vault_root_ptr] @@ -307,12 +343,15 @@ end #! Returns a boolean indicating whether the non-fungible asset is present in the vault. #! Panics if the ASSET is a fungible asset. #! -#! Stack: [ASSET] +#! Stack: [KERNEL_PROCEDURE_HASH, ASSET] #! Output: [has_asset, 0, 0, 0] #! #! - ASSET is the non-fungible asset of interest #! - has_asset is a boolean indicating whether the account vault has the asset of interest export.account_vault_has_non_fungible_asset + # drop the procedure's hash + dropw + # arrange stack and get the vault root push.0 movdn.4 push.0 movdn.4 push.0 movdn.4 exec.memory::get_acct_vault_root_ptr movdn.4 # => [ASSET, 0, 0, 0] @@ -329,7 +368,7 @@ end #! - If the total value of two fungible assets is greater than or equal to 2^63. #! - If the vault already contains the same non-fungible asset. #! -#! Stack: [ASSET] +#! Stack: [KERNEL_PROCEDURE_HASH, ASSET] #! Output: [ASSET'] #! #! - ASSET is the asset to add to the vault. @@ -338,6 +377,9 @@ end #! - If ASSET is a fungible asset, then ASSET' is the total fungible asset in the account vault #! after ASSET was added to it. export.account_vault_add_asset + # drop the procedure's hash + dropw + # authenticate that the procedure invocation originates from the account context exec.authenticate_account_origin # => [ASSET] @@ -372,11 +414,14 @@ end #! - The amount of the fungible asset in the vault is less than the amount to be removed. #! - The non-fungible asset is not found in the vault. #! -#! Stack: [ASSET] +#! Stack: [KERNEL_PROCEDURE_HASH, ASSET] #! Output: [ASSET] #! #! - ASSET is the asset to remove from the vault. export.account_vault_remove_asset + # drop the procedure's hash + dropw + # authenticate that the procedure invocation originates from the account context exec.authenticate_account_origin # => [ASSET] @@ -402,12 +447,15 @@ end #! Returns the number of assets and the assets hash of the note currently being processed. Panics #! if a note is not being processed. #! -#! Inputs: [0, 0, 0, 0, 0] +#! Inputs: [KERNEL_PROCEDURE_HASH, 0, 0, 0, 0, 0] #! Outputs: [ASSETS_HASH, num_assets] #! #! - num_assets is the number of assets in the note currently being processed. #! - ASSETS_HASH is the assets hash of the note currently being processed. export.get_note_assets_info + # drop the procedure's hash + dropw + # get the assets info exec.note::get_assets_info # => [ASSETS_HASH, num_assets, 0, 0, 0, 0, 0] @@ -419,12 +467,15 @@ end #! Returns the current note's inputs hash. #! -#! Inputs: [EMPTY_WORD] +#! Inputs: [KERNEL_PROCEDURE_HASH, EMPTY_WORD] #! Outputs: [NOTE_INPUTS_HASH] #! #! Where: #! - NOTE_INPUTS_HASH, is the current note's inputs hash. export.get_note_inputs_hash + # drop the procedure's hash + dropw + exec.note::get_note_inputs_hash # => [NOTE_INPUTS_HASH, EMPTY_WORD] @@ -435,23 +486,29 @@ end #! Returns the sender of the note currently being processed. Panics if a note is not being #! processed. #! -#! Inputs: [0] +#! Inputs: [KERNEL_PROCEDURE_HASH, 0] #! Outputs: [sender] #! #! Where: #! - sender is the sender of the note currently being processed. export.get_note_sender + # drop the procedure's hash + dropw + exec.note::get_sender swap drop # => [sender] end #! Returns the block number of the last known block at the time of transaction execution. #! -#! Inputs: [0] +#! Inputs: [KERNEL_PROCEDURE_HASH, 0] #! Outputs: [num] #! #! num is the last known block number. export.get_block_number + # drop the procedure's hash + dropw + # get the block number exec.tx::get_block_number # => [num, 0] @@ -463,12 +520,15 @@ end #! Returns the block hash of the reference block. #! -#! Stack: [EMPTY_WORD] +#! Stack: [KERNEL_PROCEDURE_HASH, EMPTY_WORD] #! Output: [BLOCK_HASH] #! #! Where: #! - BLOCK_HASH, reference block for the transaction execution. export.get_block_hash + # drop the procedure's hash + dropw + dropw exec.tx::get_block_hash # => [BLOCK_HASH] end @@ -481,12 +541,15 @@ end #! be delayed to the batch/block kernel. The delayed authentication allows a transaction to consume a #! public note that is not yet included to a block. #! -#! Inputs: [0, 0, 0, 0] +#! Inputs: [KERNEL_PROCEDURE_HASH, 0, 0, 0, 0] #! Outputs: [INPUT_NOTES_COMMITMENT] #! #! Where: #! - INPUT_NOTES_COMMITMENT is the input notes commitment hash. export.get_input_notes_commitment + # drop the procedure's hash + dropw + exec.tx::get_input_notes_commitment # => [COM, 0, 0, 0, 0] @@ -497,11 +560,14 @@ end #! Returns the output notes hash. This is computed as a sequential hash of (note_id, note_metadata) #! tuples over all output notes. #! -#! Inputs: [0, 0, 0, 0] +#! Inputs: [KERNEL_PROCEDURE_HASH, 0, 0, 0, 0] #! Outputs: [COM] #! #! COM is the output notes hash. export.get_output_notes_hash + # drop the procedure's hash + dropw + # get the output notes hash exec.tx::get_output_notes_hash # => [COM, 0, 0, 0, 0] @@ -513,7 +579,7 @@ end #! Creates a new note and returns the index of the note. #! -#! Inputs: [tag, aux, note_type, execution_hint, RECIPIENT, PAD(8)] +#! Inputs: [KERNEL_PROCEDURE_HASH, tag, aux, note_type, execution_hint, RECIPIENT, PAD(4)] #! Outputs: [note_idx, PAD(15)] #! #! tag is the tag to be included in the note. @@ -523,6 +589,9 @@ end #! RECIPIENT is the recipient of the note. #! note_idx is the index of the crated note. export.create_note + # drop the procedure's hash + dropw + # authenticate that the procedure invocation originates from the account context exec.authenticate_account_origin # => [tag, aux, note_type, execution_hint, RECIPIENT, PAD(8)] @@ -533,12 +602,15 @@ end #! Adds the ASSET to the note specified by the index. #! -#! Inputs: [note_idx, ASSET, PAD(11)] +#! Inputs: [KERNEL_PROCEDURE_HASH, note_idx, ASSET, PAD(7)] #! Outputs: [note_idx, ASSET, PAD(11)] #! #! note_idx is the index of the the note to which the asset is added. #! ASSET can be a fungible or non-fungible asset. export.add_asset_to_note + # drop the procedure's hash + dropw + # authenticate that the procedure invocation originates from the account context exec.authenticate_account_origin # => [note_idx, ASSET] @@ -553,11 +625,14 @@ end #! Returns a commitment to the account vault the transaction is being executed against. #! -#! Stack: [0, 0, 0, 0] +#! Stack: [KERNEL_PROCEDURE_HASH, 0, 0, 0, 0] #! Outputs: [COM] #! #! - COM is the commitment to the account vault. export.get_account_vault_commitment + # drop the procedure's hash + dropw + # fetch the account vault root exec.memory::get_acct_vault_root # => [COM, 0, 0, 0, 0] @@ -578,11 +653,14 @@ end #! allowed. #! - For non-fungible faucets if the non-fungible asset being minted already exists. #! -#! Stack: [ASSET] +#! Stack: [KERNEL_PROCEDURE_HASH, ASSET] #! Outputs: [ASSET] #! #! - ASSET is the asset that was minted. export.mint_asset + # drop the procedure's hash + dropw + # authenticate that the procedure invocation originates from the account context exec.authenticate_account_origin # => [ASSET] @@ -604,11 +682,14 @@ end #! - For non-fungible faucets if the non-fungible asset being burned does not exist or was not #! provided as input to the transaction via a note or the accounts vault. #! -#! Stack: [ASSET] +#! Stack: [KERNEL_PROCEDURE_HASH, ASSET] #! Outputs: [ASSET] #! #! - ASSET is the asset that was burned. export.burn_asset + # drop the procedure's hash + dropw + # authenticate that the procedure invocation originates from the account context exec.authenticate_account_origin # => [ASSET] @@ -623,12 +704,15 @@ end #! Panics: #! - If the transaction is not being executed against a fungible faucet. #! -#! Stack: [0] +#! Stack: [KERNEL_PROCEDURE_HASH, 0] #! Outputs: [total_issuance] #! #! - total_issuance is the total issuance of the fungible faucet the transaction is being executed #! against. export.get_fungible_faucet_total_issuance + # drop the procedure's hash + dropw + # assert that we are executing a transaction against a fungible faucet (access checks) exec.account::get_id exec.account::is_fungible_faucet assert.err=ERR_ACCT_MUST_BE_A_FAUCET # => [0] @@ -645,11 +729,14 @@ end #! Returns the serial number of the note currently being processed. #! Panics if no note is not being processed. #! -#! Inputs: [] +#! Inputs: [KERNEL_PROCEDURE_HASH] #! Outputs: [SERIAL_NUMBER] #! #! - SERIAL_NUMBER is the serial number of the note currently being processed. export.get_note_serial_number + # drop the procedure's hash + dropw + exec.note::get_serial_number # => [SERIAL_NUMBER] @@ -658,21 +745,29 @@ export.get_note_serial_number # => [SERIAL_NUMBER] end -#! Executes a kernel procedure specified by its memory pointer +#! Executes a kernel procedure specified by its offset. #! -#! Inputs: [procedure_ptr] -#! Outputs: [*executed_procedure_output*] +#! Inputs: [procedure_offset, *executed_procedure_input*, PAD(*)] +#! Outputs: [*executed_procedure_output*, PAD(*)] #! -#! - procedure_ptr is a pointer to the memory where hash of the desired kernel procedure is stored. +#! - procedure_offset is an offset of the kernel procedure, specified in the +#! `miden/kernel_invocation.masm` file. export.exec_kernel_proc + # compute the memory pointer at which desired procedure is stored + exec.memory::get_kernel_procedures_ptr add + # => [procedure_pointer, *executed_procedure_input*, PAD(*)] + # prepare stack for procedure hash obtaining padw movup.4 - # => [procedure_ptr, 0, 0, 0, 0] + # => [procedure_pointer, 0, 0, 0, 0, *executed_procedure_input*, PAD(*)] # load kernel procedure hash mem_loadw - # => [KERNEL_PROCEDURE_HASH] + # => [KERNEL_PROCEDURE_HASH, *executed_procedure_input*, PAD(*)] # execute loaded procedure dynexec + # => [*executed_procedure_output*, PAD(*)] + + exec.sys::truncate_stack end diff --git a/miden-lib/asm/kernels/transaction/lib/memory.masm b/miden-lib/asm/kernels/transaction/lib/memory.masm index 92bc6a233..adc891027 100644 --- a/miden-lib/asm/kernels/transaction/lib/memory.masm +++ b/miden-lib/asm/kernels/transaction/lib/memory.masm @@ -131,37 +131,7 @@ const.ACCT_PROCEDURES_SECTION_OFFSET=1000 # The memory address at which the hashes of kernel procedures begin. # TODO: choose the proper memory location for the kernel procedures. -const.KERNEL_PROCEDURES_PTR=1500 - -# The offsets at which hash of the corresponding procedure is stored. -const.GET_ACCOUNT_ID_PTR=KERNEL_PROCEDURES_PTR -const.GET_ACCOUNT_NONCE_PTR=KERNEL_PROCEDURES_PTR+1 -const.GET_INITIAL_ACCOUNT_HASH_PTR=KERNEL_PROCEDURES_PTR+2 -const.GET_CURRENT_ACCOUNT_HASH_PTR=KERNEL_PROCEDURES_PTR+3 -const.INCR_ACCOUNT_NONCE_PTR=KERNEL_PROCEDURES_PTR+4 -const.GET_ACCOUNT_ITEM_PTR=KERNEL_PROCEDURES_PTR+5 -const.SET_ACCOUNT_ITEM_PTR=KERNEL_PROCEDURES_PTR+6 -const.GET_ACCOUNT_MAP_ITEM_PTR=KERNEL_PROCEDURES_PTR+7 -const.SET_ACCOUNT_MAP_ITEM_PTR=KERNEL_PROCEDURES_PTR+8 -const.SET_ACCOUNT_CODE_PTR=KERNEL_PROCEDURES_PTR+9 -const.ACCOUNT_VAULT_GET_BALANCE_PTR=KERNEL_PROCEDURES_PTR+10 -const.ACCOUNT_VAULT_HAS_NON_FUNGIBLE_ASSET_PTR=KERNEL_PROCEDURES_PTR+11 -const.ACCOUNT_VAULT_ADD_ASSET_PTR=KERNEL_PROCEDURES_PTR+12 -const.ACCOUNT_VAULT_REMOVE_ASSET_PTR=KERNEL_PROCEDURES_PTR+13 -const.GET_NOTE_ASSETS_INFO_PTR=KERNEL_PROCEDURES_PTR+14 -const.GET_NOTE_INPUTS_HASH_PTR=KERNEL_PROCEDURES_PTR+15 -const.GET_NOTE_SENDER_PTR=KERNEL_PROCEDURES_PTR+16 -const.GET_BLOCK_NUMBER_PTR=KERNEL_PROCEDURES_PTR+17 -const.GET_BLOCK_HASH_PTR=KERNEL_PROCEDURES_PTR+18 -const.GET_INPUT_NOTES_COMMITMENT_PTR=KERNEL_PROCEDURES_PTR+19 -const.GET_OUTPUT_NOTES_HASH_PTR=KERNEL_PROCEDURES_PTR+20 -const.CREATE_NOTE_PTR=KERNEL_PROCEDURES_PTR+21 -const.ADD_ASSET_TO_NOTE_PTR=KERNEL_PROCEDURES_PTR+22 -const.GET_ACCOUNT_VAULT_COMMITMENT_PTR=KERNEL_PROCEDURES_PTR+23 -const.MINT_ASSET_PTR=KERNEL_PROCEDURES_PTR+24 -const.BURN_ASSET_PTR=KERNEL_PROCEDURES_PTR+25 -const.GET_FUNGIBLE_FAUCET_TOTAL_ISSUANCE_PTR=KERNEL_PROCEDURES_PTR+26 -const.GET_NOTE_SERIAL_NUMBER_PTR=KERNEL_PROCEDURES_PTR+27 +const.KERNEL_PROCEDURES_PTR=10000 # INPUT NOTES DATA # ------------------------------------------------------------------------------------------------- @@ -471,10 +441,10 @@ end #! Returns the previous block hash of the last known block. #! #! Stack: [] -#! Output: [PRV_BLK_HASH] +#! Output: [PREV_BLOCK_HASH] #! #! Where: -#! - PRV_BLK_HASH is the previous block hash of the last known block. +#! - PREV_BLOCK_HASH is the previous block hash of the last known block. export.get_prv_blk_hash padw push.PREV_BLOCK_HASH_PTR mem_loadw end @@ -512,7 +482,6 @@ export.get_blk_timestamp padw push.BLOCK_METADATA_PTR mem_loadw drop movdn.2 drop drop end - #! Returns the chain root of the last known block. #! #! Stack: [] @@ -1212,11 +1181,11 @@ end #! Stack: [note_ptr, num_assets] #! Output: [] #! -#! Panics: if the number of assets exceeds the maximum allowed number of assets per note. -#! #! Where: #! - note_ptr is the memory address at which the output note data begins. #! - num_assets is the number of assets in the output note. +#! +#! Panics: if the number of assets exceeds the maximum allowed number of assets per note. export.set_output_note_num_assets push.OUTPUT_NOTE_NUM_ASSETS_OFFSET add # => [note_ptr + offset, num_assets] @@ -1258,343 +1227,10 @@ end #! Returns a pointer to the memory where hashes of the kernel procedures are stored. #! #! Stack: [] -#! Output: [kernel_procs_ptr] +#! Output: [kernel_procedures_ptr] #! #! Where: -#! - kernel_procs_ptr is the memory address where the hashes of the kernel procedures are stored. -export.get_kernel_procs_ptr +#! - kernel_procedures_ptr is the memory address where the hashes of the kernel procedures are stored. +export.get_kernel_procedures_ptr push.KERNEL_PROCEDURES_PTR end - -#! Returns a pointer to the hash of the `get_account_id` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_account_id` kernel procedure is -#! stored. -export.get_account_id_ptr - push.GET_ACCOUNT_ID_PTR -end - -#! Returns a pointer to the hash of the `get_account_nonce` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_account_nonce` kernel procedure is -#! stored. -export.get_account_nonce_ptr - push.GET_ACCOUNT_NONCE_PTR -end - -#! Returns a pointer to the hash of the `get_initial_account_hash` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_initial_account_hash` kernel -#! procedure is stored. -export.get_initial_account_hash_ptr - push.GET_INITIAL_ACCOUNT_HASH_PTR -end - -#! Returns a pointer to the hash of the `get_current_account_hash` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_current_account_hash` kernel -#! procedure is stored. -export.get_current_account_hash_ptr - push.GET_CURRENT_ACCOUNT_HASH_PTR -end - -#! Returns a pointer to the hash of the `incr_account_nonce` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `incr_account_nonce` kernel procedure is -#! stored. -export.incr_account_nonce_ptr - push.INCR_ACCOUNT_NONCE_PTR -end - -#! Returns a pointer to the hash of the `get_account_item` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_account_item` kernel procedure is -#! stored. -export.get_account_item_ptr - push.GET_ACCOUNT_ITEM_PTR -end - -#! Returns a pointer to the hash of the `set_account_item` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `set_account_item` kernel procedure is -#! stored. -export.set_account_item_ptr - push.SET_ACCOUNT_ITEM_PTR -end - -#! Returns a pointer to the hash of the `get_account_map_item` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_account_map_item` kernel procedure is -#! stored. -export.get_account_map_item_ptr - push.GET_ACCOUNT_MAP_ITEM_PTR -end - -#! Returns a pointer to the hash of the `set_account_map_item` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `set_account_map_item` kernel procedure is -#! stored. -export.set_account_map_item_ptr - push.SET_ACCOUNT_MAP_ITEM_PTR -end - -#! Returns a pointer to the hash of the `set_account_code` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `set_account_code` kernel procedure is -#! stored. -export.set_account_code_item_ptr - push.SET_ACCOUNT_CODE_PTR -end - -#! Returns a pointer to the hash of the `account_vault_get_balance` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `account_vault_get_balance` kernel -#! procedure is stored. -export.account_vault_get_balance_ptr - push.ACCOUNT_VAULT_GET_BALANCE_PTR -end - -#! Returns a pointer to the hash of the `account_vault_has_non_fungible_asset` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `account_vault_has_non_fungible_asset` -#! kernel procedure is stored. -export.account_vault_has_non_fungible_asset_ptr - push.ACCOUNT_VAULT_HAS_NON_FUNGIBLE_ASSET_PTR -end - -#! Returns a pointer to the hash of the `account_vault_add_asset` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `account_vault_add_asset` kernel procedure -#! is stored. -export.account_vault_add_asset_ptr - push.ACCOUNT_VAULT_ADD_ASSET_PTR -end - -#! Returns a pointer to the hash of the `account_vault_remove_asset` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `account_vault_remove_asset` kernel -#! procedure is stored. -export.account_vault_remove_asset_ptr - push.ACCOUNT_VAULT_REMOVE_ASSET_PTR -end - -#! Returns a pointer to the hash of the `get_note_assets_info` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_note_assets_info` kernel procedure -#! is stored. -export.get_note_assets_info_ptr - push.GET_NOTE_ASSETS_INFO_PTR -end - -#! Returns a pointer to the hash of the `get_note_inputs_hash` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_note_inputs_hash` kernel procedure -#! is stored. -export.get_note_inputs_hash_ptr - push.GET_NOTE_INPUTS_HASH_PTR -end - -#! Returns a pointer to the hash of the `get_note_sender` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_note_sender` kernel procedure is -#! stored. -export.get_note_sender_ptr - push.GET_NOTE_SENDER_PTR -end - -#! Returns a pointer to the hash of the `get_block_number` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_block_number` kernel procedure is -#! stored. -export.get_block_number_ptr - push.GET_BLOCK_NUMBER_PTR -end - -#! Returns a pointer to the hash of the `get_block_hash` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_block_hash` kernel procedure is -#! stored. -export.get_block_hash_ptr - push.GET_BLOCK_HASH_PTR -end - -#! Returns a pointer to the hash of the `get_input_notes_commitment` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_input_notes_commitment` kernel -#! procedure is stored. -export.get_input_notes_commitment_ptr - push.GET_INPUT_NOTES_COMMITMENT_PTR -end - -#! Returns a pointer to the hash of the `get_output_notes_hash` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_output_notes_hash` kernel procedure -#! is stored. -export.get_output_notes_hash_ptr - push.GET_OUTPUT_NOTES_HASH_PTR -end - -#! Returns a pointer to the hash of the `create_note` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `create_note` kernel procedure is stored. -export.create_note_ptr - push.CREATE_NOTE_PTR -end - -#! Returns a pointer to the hash of the `add_asset_to_note` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `add_asset_to_note` kernel procedure is -#! stored. -export.add_asset_to_note_ptr - push.ADD_ASSET_TO_NOTE_PTR -end - -#! Returns a pointer to the hash of the `get_account_vault_commitment` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_account_vault_commitment` kernel -#! procedure is stored. -export.get_account_vault_commitment_ptr - push.GET_ACCOUNT_VAULT_COMMITMENT_PTR -end - -#! Returns a pointer to the hash of the `mint_asset` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `mint_asset` kernel procedure is stored. -export.mint_asset_ptr - push.MINT_ASSET_PTR -end - -#! Returns a pointer to the hash of the `burn_asset` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `burn_asset` kernel procedure is stored. -export.burn_asset_ptr - push.BURN_ASSET_PTR -end - -#! Returns a pointer to the hash of the `get_fungible_faucet_total_issuance` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_fungible_faucet_total_issuance` -#! kernel procedure is stored. -export.get_fungible_faucet_total_issuance_ptr - push.GET_FUNGIBLE_FAUCET_TOTAL_ISSUANCE_PTR -end - -#! Returns a pointer to the hash of the `get_note_serial_number` kernel procedure. -#! -#! Stack: [] -#! Output: [proc_ptr] -#! -#! Where: -#! - proc_ptr is the memory address where the hash of the `get_note_serial_number` kernel procedure -#! is stored. -export.get_note_serial_number_ptr - push.GET_NOTE_SERIAL_NUMBER_PTR -end diff --git a/miden-lib/asm/kernels/transaction/lib/prologue.masm b/miden-lib/asm/kernels/transaction/lib/prologue.masm index b6a2ae90d..5c1fb43cb 100644 --- a/miden-lib/asm/kernels/transaction/lib/prologue.masm +++ b/miden-lib/asm/kernels/transaction/lib/prologue.masm @@ -116,7 +116,7 @@ end #! - [KERNEL_PROCS], array of hashes of the kernel procedures. proc.process_kernel_data # get the pointer to the memory where hashes of the kernel procedures will be stored - exec.memory::get_kernel_procs_ptr swap + exec.memory::get_kernel_procedures_ptr swap # => [kernel_procs_len, kernel_procs_ptr, KERNEL_HASH] # store the kernel procedures to the memory @@ -125,9 +125,6 @@ proc.process_kernel_data drop # => [] - - # kernel hash - # 14953775620698834032, 17523231931899419664, 4825234885919677706, 11125827748116184971 end # BLOCK DATA diff --git a/miden-lib/asm/miden/account.masm b/miden-lib/asm/miden/account.masm index 63c8687d5..c4399c3ee 100644 --- a/miden-lib/asm/miden/account.masm +++ b/miden-lib/asm/miden/account.masm @@ -1,4 +1,4 @@ -use.kernel::transaction::lib::memory +use.miden::kernel_invocation #! Returns the account id. #! @@ -10,8 +10,21 @@ export.get_id push.0 # => [0] - exec.memory::get_account_id_ptr + # start padding the stack + push.0.0 + + exec.kernel_invocation::get_account_id_offset + # => [offset, 0, 0, 0] + + # pad the stack + padw swapw padw padw swapdw + # => [offset, 0, PAD(14)] + syscall.exec_kernel_proc + # => [acct_id, PAD(15)] + + # clean the stack + swapdw dropw dropw swapw dropw movdn.3 drop drop drop # => [acct_id] end @@ -25,8 +38,21 @@ export.get_nonce push.0 # => [0] - exec.memory::get_account_nonce_ptr + # start padding the stack + push.0.0 + + exec.kernel_invocation::get_account_nonce_offset + # => [offset, 0, 0, 0] + + # pad the stack + padw swapw padw padw swapdw + # => [offset, PAD(15)] + syscall.exec_kernel_proc + # => [nonce, PAD(15)] + + # clean the stack + swapdw dropw dropw swapw dropw movdn.3 drop drop drop # => [nonce] end @@ -37,11 +63,18 @@ end #! #! - H is the initial account hash. export.get_initial_hash - padw - # => [0, 0, 0, 0] + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15)] + + exec.kernel_invocation::get_initial_account_hash_offset + # => [offset, PAD(15)] - exec.memory::get_initial_account_hash_ptr syscall.exec_kernel_proc + # => [H, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw # => [H] end @@ -52,11 +85,18 @@ end #! #! - ACCT_HASH is the hash of the account data. export.get_current_hash - padw - # => [0, 0, 0, 0] + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15)] + + exec.kernel_invocation::get_current_account_hash_offset + # => [offset, PAD(15)] - exec.memory::get_current_account_hash_ptr syscall.exec_kernel_proc + # => [ACCT_HASH, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw # => [ACCT_HASH] end @@ -68,12 +108,21 @@ end #! - value is the value to increment the nonce by. value can be at most 2^32 - 1 otherwise this #! procedure panics. export.incr_nonce - exec.memory::incr_account_nonce_ptr + # start padding the stack + push.0.0 movup.2 + # => [value, 0, 0] + + exec.kernel_invocation::incr_account_nonce_offset + # => [offset, value, 0, 0] + + # pad the stack + padw swapw padw padw swapdw + # => [offset, value, PAD(14)] + syscall.exec_kernel_proc - # => [0] + # => [PAD(16)] - drop - # => [] + dropw dropw dropw dropw end #! Gets an item from the account storage. Panics if the index is out of bounds. @@ -84,11 +133,21 @@ end #! - index is the index of the item to get. #! - VALUE is the value of the item. export.get_item - push.0.0.0 movup.3 - # => [index, 0, 0, 0] + push.0.0 movup.2 + # => [index, 0, 0] + + exec.kernel_invocation::get_account_item_offset + # => [offset, index, 0, 0] + + # pad the stack + padw swapw padw padw swapdw + # => [offset, index, PAD(14)] - exec.memory::get_account_item_ptr syscall.exec_kernel_proc + # => [VALUE, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw # => [VALUE] end @@ -102,12 +161,18 @@ end #! - V is the previous value of the item. #! - R' is the new storage root. export.set_item - push.0 movdn.5 push.0 movdn.5 push.0 movdn.5 - # => [index, V', 0, 0, 0] + exec.kernel_invocation::set_account_item_offset + # => [offset, index, V'] - exec.memory::set_account_item_ptr + # pad the stack + push.0.0 movdn.7 movdn.7 padw padw swapdw + # => [offset, index, V', PAD(10)] + syscall.exec_kernel_proc - # => [R', V] + # => [R', V, PAD(8)] + + # clean the stack + swapdw dropw dropw end #! Gets a map item from the account storage. Panics if @@ -121,13 +186,19 @@ end #! - KEY is the key of the item to get. #! - VALUE is the value of the item. export.get_map_item - exec.memory::get_account_map_item_ptr + exec.kernel_invocation::get_account_map_item_offset + # => [offset, index, KEY] + + # pad the stack + push.0.0 movdn.7 movdn.7 padw padw swapdw + # => [offset, index, KEY, PAD(10)] + syscall.exec_kernel_proc - # => [VALUE] + # => [VALUE, PAD(12)] - # prepare stack for return - movup.5 drop - # => [VALUE, 0] + # clean the stack + swapdw dropw dropw swapw dropw + # => [VALUE] end #! Sets a map item in the account storage. Panics if @@ -143,11 +214,18 @@ end #! - OLD_MAP_ROOT is the old map root. #! - OLD_MAP_VALUE is the old value at KEY. export.set_map_item - exec.memory::set_account_map_item_ptr + exec.kernel_invocation::set_account_map_item_offset + # => [offset, index, KEY, VALUE] + + # pad the stack + push.0.0 movdn.11 movdn.11 padw movdnw.3 + # => [offset, index, KEY, VALUE, PAD(6)] + syscall.exec_kernel_proc - # => [OLD_MAP_ROOT, OLD_MAP_VALUE, 0] + # => [OLD_MAP_ROOT, OLD_MAP_VALUE, PAD(8)] - movup.8 drop + # clean the stack + swapdw dropw dropw # => [OLD_MAP_ROOT, OLD_MAP_VALUE] end @@ -159,11 +237,18 @@ end #! #! - CODE_COMMITMENT is the hash of the code to set. export.set_code - exec.memory::set_account_code_ptr + exec.kernel_invocation::set_account_code_offset + # => [offset, CODE_COMMITMENT] + + # pad the stack + push.0.0.0 movdn.7 movdn.7 movdn.7 padw padw swapdw + # => [offset, CODE_COMMITMENT, PAD(11)] + syscall.exec_kernel_proc - # => [0, 0, 0, 0] + # => [PAD(16)] - dropw + # clean the stack + dropw dropw dropw dropw # => [] end @@ -176,8 +261,18 @@ end #! - faucet_id is the faucet id of the fungible asset of interest. #! - balance is the vault balance of the fungible asset. export.get_balance - exec.memory::account_vault_get_balance_ptr + exec.kernel_invocation::account_vault_get_balance_offset + # => [offset, faucet_id] + + # pad the stack + push.0.0 movdn.3 movdn.3 padw swapw padw padw swapdw + # => [offset, faucet_id, PAD(14)] + syscall.exec_kernel_proc + # => [balance, PAD(15)] + + # clean the stack + swapdw dropw dropw swapw dropw movdn.3 drop drop drop # => [balance] end @@ -190,11 +285,18 @@ end #! - ASSET is the non-fungible asset of interest #! - has_asset is a boolean indicating whether the account vault has the asset of interest export.has_non_fungible_asset - exec.memory::account_vault_has_non_fungible_asset_ptr + exec.kernel_invocation::account_vault_has_non_fungible_asset_offset + # => [offset, ASSET] + + # pad the stack + push.0.0.0 movdn.7 movdn.7 movdn.7 padw padw swapdw + # => [offset, ASSET, PAD(11)] + syscall.exec_kernel_proc - # => [has_asset, 0, 0, 0] + # => [has_asset, PAD(15)] - swap drop swap drop swap drop + # clean the stack + swapdw dropw dropw swapw dropw movdn.3 drop drop drop # => [has_asset] end @@ -213,8 +315,19 @@ end #! - If ASSET is a fungible asset, then ASSET' is the total fungible asset in the account vault #! after ASSET was added to it. export.add_asset - exec.memory::account_vault_add_asset_ptr + exec.kernel_invocation::account_vault_add_asset_offset + # => [offset, ASSET] + + # pad the stack + push.0.0.0 movdn.7 movdn.7 movdn.7 padw padw swapdw + # => [offset, ASSET, PAD(11)] + syscall.exec_kernel_proc + # => [ASSET', PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw + # => [ASSET'] end #! Remove the specified asset from the vault. @@ -229,8 +342,19 @@ end #! #! - ASSET is the asset to remove from the vault. export.remove_asset - exec.memory::account_vault_remove_asset_ptr + exec.kernel_invocation::account_vault_remove_asset_offset + # => [offset, ASSET] + + # pad the stack + push.0.0.0 movdn.7 movdn.7 movdn.7 padw padw swapdw + # => [offset, ASSET, PAD(11)] + syscall.exec_kernel_proc + # => [ASSET, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw + # => [ASSET] end #! Returns a commitment to the account vault. @@ -241,12 +365,17 @@ end #! - COM is a commitment to the account vault. export.get_vault_commitment # pad the stack for syscall invocation - padw - # => [0, 0, 0, 0] + padw padw padw push.0.0.0 + # => [PAD(15)] + + exec.kernel_invocation::get_account_vault_commitment_offset + # => [offset, PAD(15)] - # invoke the syscall - exec.memory::get_account_vault_commitment_ptr syscall.exec_kernel_proc + # => [COM, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw # => [COM] end diff --git a/miden-lib/asm/miden/faucet.masm b/miden-lib/asm/miden/faucet.masm index 2a2640757..f7b333072 100644 --- a/miden-lib/asm/miden/faucet.masm +++ b/miden-lib/asm/miden/faucet.masm @@ -1,4 +1,4 @@ -use.miden::kernels::tx::memory +use.miden::kernel_invocation #! Mint an asset from the faucet the transaction is being executed against. #! @@ -16,8 +16,18 @@ use.miden::kernels::tx::memory #! #! - ASSET is the asset that was minted. export.mint - exec.memory::mint_asset_ptr + exec.kernel_invocation::mint_asset_offset + # => [offset, ASSET] + + # pad the stack + push.0.0.0 movdn.7 movdn.7 movdn.7 padw padw swapdw + # => [offset, ASSET, PAD(11)] + syscall.exec_kernel_proc + # => [ASSET, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw # => [ASSET] end @@ -38,8 +48,18 @@ end #! #! - ASSET is the asset that was burned. export.burn - exec.memory::burn_asset_ptr + exec.kernel_invocation::burn_asset_offset + # => [offset, ASSET] + + # pad the stack + push.0.0.0 movdn.7 movdn.7 movdn.7 padw padw swapdw + # => [offset, ASSET, PAD(11)] + syscall.exec_kernel_proc + # => [ASSET, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw # => [ASSET] end @@ -54,12 +74,17 @@ end #! - total_issuance is the total issuance of the fungible faucet the transaction is being executed #! against. export.get_total_issuance - # add padding to the stack for kernel invocation - push.0 - # => [0] + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15)] + + exec.kernel_invocation::get_fungible_faucet_total_issuance_offset + # => [offset, PAD(15)] - # invoke the `get_fungible_faucet_total_issuance` kernel procedure - exec.memory::get_fungible_faucet_total_issuance_ptr syscall.exec_kernel_proc + # => [total_issuance, PAD(15)] + + # clean the stack + swapdw dropw dropw swapw dropw movdn.3 drop drop drop # => [total_issuance] end diff --git a/miden-lib/asm/miden/kernel_invocation.masm b/miden-lib/asm/miden/kernel_invocation.masm new file mode 100644 index 000000000..1db22ab12 --- /dev/null +++ b/miden-lib/asm/miden/kernel_invocation.masm @@ -0,0 +1,375 @@ +# KERNEL PROCEDURE OFFSETS +# ================================================================================================= + +# OFFSET CONSTANTS +# ------------------------------------------------------------------------------------------------- + +# The offsets at which hash of the corresponding procedure is stored. +# const.EXEC_KERNEL_PROC_OFFSET=0 +const.ACCOUNT_VAULT_GET_BALANCE_OFFSET=1 +const.GET_ACCOUNT_MAP_ITEM_OFFSET=2 +const.GET_ACCOUNT_ITEM_OFFSET=3 +const.GET_CURRENT_ACCOUNT_HASH_OFFSET=4 +const.GET_ACCOUNT_NONCE_OFFSET=5 +const.SET_ACCOUNT_ITEM_OFFSET=6 +const.GET_INITIAL_ACCOUNT_HASH_OFFSET=7 +const.MINT_ASSET_OFFSET=8 +const.GET_ACCOUNT_ID_OFFSET=9 +const.ACCOUNT_VAULT_HAS_NON_FUNGIBLE_ASSET_OFFSET=10 +const.BURN_ASSET_OFFSET=11 +const.INCR_ACCOUNT_NONCE_OFFSET=12 +const.CREATE_NOTE_OFFSET=13 +const.GET_FUNGIBLE_FAUCET_TOTAL_ISSUANCE_OFFSET=14 +const.GET_BLOCK_HASH_OFFSET=15 +const.GET_BLOCK_NUMBER_OFFSET=16 +const.ACCOUNT_VAULT_ADD_ASSET_OFFSET=17 +const.GET_NOTE_SERIAL_NUMBER_OFFSET=18 +const.GET_ACCOUNT_VAULT_COMMITMENT_OFFSET=19 +const.ACCOUNT_VAULT_REMOVE_ASSET_OFFSET=20 +const.SET_ACCOUNT_CODE_OFFSET=21 +const.GET_NOTE_ASSETS_INFO_OFFSET=22 +const.GET_NOTE_SENDER_OFFSET=23 +const.SET_ACCOUNT_MAP_ITEM_OFFSET=24 +const.GET_NOTE_INPUTS_HASH_OFFSET=25 +const.ADD_ASSET_TO_NOTE_OFFSET=26 +const.GET_OUTPUT_NOTES_HASH_OFFSET=27 +const.GET_INPUT_NOTES_COMMITMENT_OFFSET=28 + +# ACCESSORS +# ------------------------------------------------------------------------------------------------- + +#! Returns an offset of the `get_account_id` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `get_account_nonce` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `get_initial_account_hash` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `get_current_account_hash` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `incr_account_nonce` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - 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 +end + +#! Returns an offset of the `get_account_item` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - 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 +end + +#! Returns an offset of the `set_account_item` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - 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 +end + +#! Returns an offset of the `get_account_map_item` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - 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 +end + +#! Returns an offset of the `set_account_map_item` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - 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. +#! +#! Stack: [] +#! Output: [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. +#! +#! Stack: [] +#! Output: [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. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `account_vault_add_asset` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - proc_offset is the offset of the `account_vault_add_asset` kernel procedure required to get the +#! address where this procedure is stored. +export.account_vault_add_asset_offset + push.ACCOUNT_VAULT_ADD_ASSET_OFFSET +end + +#! Returns an offset of the `account_vault_remove_asset` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - proc_offset is the offset of the `account_vault_remove_asset` kernel procedure required to get +#! the address where this procedure is stored. +export.account_vault_remove_asset_offset + push.ACCOUNT_VAULT_REMOVE_ASSET_OFFSET +end + +#! Returns an offset of the `get_note_assets_info` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `get_note_inputs_hash` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `get_note_sender` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `get_block_number` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `get_block_hash` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - 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.GET_BLOCK_HASH_OFFSET +end + +#! Returns an offset of the `get_input_notes_commitment` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - 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 +end + +#! Returns an offset of the `get_output_notes_hash` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - proc_offset is the offset of the `get_output_notes_hash` kernel procedure required to get the +#! address where this procedure is stored. +export.get_output_notes_hash_offset + push.GET_OUTPUT_NOTES_HASH_OFFSET +end + +#! Returns an offset of the `create_note` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `add_asset_to_note` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - 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.ADD_ASSET_TO_NOTE_OFFSET +end + +#! Returns an offset of the `get_account_vault_commitment` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `mint_asset` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `burn_asset` kernel procedure. +#! +#! Stack: [] +#! Output: [proc_offset] +#! +#! Where: +#! - 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.BURN_ASSET_OFFSET +end + +#! Returns an offset of the `get_fungible_faucet_total_issuance` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end + +#! Returns an offset of the `get_note_serial_number` kernel procedure. +#! +#! Stack: [] +#! Output: [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 +end \ No newline at end of file diff --git a/miden-lib/asm/miden/note.masm b/miden-lib/asm/miden/note.masm index ca9da2fd5..1b67227cc 100644 --- a/miden-lib/asm/miden/note.masm +++ b/miden-lib/asm/miden/note.masm @@ -1,4 +1,4 @@ -use.miden::kernels::tx::memory +use.miden::kernel_invocation use.std::crypto::hashes::native use.std::mem @@ -46,12 +46,18 @@ end #! - dest_ptr is the memory address to write the assets. #! - num_assets is the number of assets in the currently executing note. export.get_assets - padw push.0 - # => [0, 0, 0, 0, 0, dest_ptr] + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15), dest_ptr] + + exec.kernel_invocation::get_note_assets_info_offset + # => [offset, PAD(15), dest_ptr] - # get the current input note assets info - exec.memory::get_note_assets_info_ptr syscall.exec_kernel_proc + # => [ASSETS_HASH, num_assets, PAD(11), dest_ptr] + + # clean the stack + swapdw dropw dropw movup.7 movup.7 movup.7 drop drop drop # => [ASSETS_HASH, num_assets, dest_ptr] # load the asset data from the advice map to the advice stack @@ -85,9 +91,18 @@ end #! - inputs_len, the note's input count. #! - INPUTS, the data corresponding to the note's inputs. export.get_inputs - padw - exec.memory::get_note_inputs_hash_ptr + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15), dest_ptr] + + exec.kernel_invocation::get_note_inputs_hash_offset + # => [offset, PAD(15), dest_ptr] + syscall.exec_kernel_proc + # => [INPUTS_HASH, PAD(12), dest_ptr] + + # clean the stack + swapdw dropw dropw swapw dropw # => [INPUTS_HASH, dest_ptr] # load the inputs from the advice map to the advice stack @@ -126,11 +141,18 @@ end #! #! - sender is the sender of the note currently being processed. export.get_sender - push.0 - # => [0] + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15)] + + exec.kernel_invocation::get_note_sender_offset + # => [offset, PAD(15)] - exec.memory::get_note_sender_ptr syscall.exec_kernel_proc + # => [sender, PAD(15)] + + # clean the stack + swapdw dropw dropw swapw dropw movdn.3 drop drop drop # => [sender] end @@ -142,11 +164,18 @@ end #! #! - SERIAL_NUMBER is the serial number of the note currently being processed. export.get_serial_number - padw - # => [0, 0, 0, 0] + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15)] + + exec.kernel_invocation::get_note_serial_number_offset + # => [offset, PAD(15)] - exec.memory::get_note_serial_number_ptr syscall.exec_kernel_proc + # => [SERIAL_NUMBER, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw # => [SERIAL_NUMBER] end diff --git a/miden-lib/asm/miden/tx.masm b/miden-lib/asm/miden/tx.masm index e9cf33d7e..8178d300f 100644 --- a/miden-lib/asm/miden/tx.masm +++ b/miden-lib/asm/miden/tx.masm @@ -1,4 +1,4 @@ -use.miden::kernels::tx::memory +use.miden::kernel_invocation #! Returns the block number of the last known block at the time of transaction execution. #! @@ -7,11 +7,18 @@ use.miden::kernels::tx::memory #! #! num is the last known block number. export.get_block_number - push.0 - # => [0] + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15)] + + exec.kernel_invocation::get_block_number_offset + # => [offset, PAD(15)] - exec.memory::get_block_number_ptr syscall.exec_kernel_proc + # => [num, PAD(15)] + + # clean the stack + swapdw dropw dropw swapw dropw movdn.3 drop drop drop # => [num] end @@ -23,9 +30,18 @@ end #! Where: #! - BLOCK_HASH, reference block for the transaction execution. export.get_block_hash - padw - exec.memory::get_block_hash_ptr + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15)] + + exec.kernel_invocation::get_block_hash_offset + # => [offset, PAD(15)] + syscall.exec_kernel_proc + # => [BLOCK_HASH, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw # => [BLOCK_HASH] end @@ -39,10 +55,19 @@ end #! Where: #! - INPUT_NOTES_COMMITMENT is the input notes commitment hash. export.get_input_notes_commitment - padw - exec.memory::get_input_notes_commitment_ptr + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15)] + + exec.kernel_invocation::get_input_notes_commitment_offset + # => [offset, PAD(15)] + syscall.exec_kernel_proc - # => [INPUT_NOTES_COMMITMENT] + # => [INPUT_NOTES_COMMITMENT, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw + # => [INPUT_NOTES_COMMITMENT] end #! Returns the output notes hash. This is computed as a sequential hash of (note_id, note_metadata) @@ -53,12 +78,19 @@ end #! #! COM is the output notes hash. export.get_output_notes_hash - padw - # => [0, 0, 0, 0] + # pad the stack + padw padw padw push.0.0.0 + # => [PAD(15)] + + exec.kernel_invocation::get_output_notes_hash_offset + # => [offset, PAD(15)] - exec.memory::get_output_notes_hash_ptr syscall.exec_kernel_proc - # => [COM] + # => [COM, PAD(12)] + + # clean the stack + swapdw dropw dropw swapw dropw + # => [COM] end #! Creates a new note and returns the index of the note. @@ -75,10 +107,12 @@ end export.create_note # pad the stack before the syscall to prevent accidental modification of the deeper stack # elements - padw padw swapdw - # => [tag, aux, note_type, execution_hint, RECIPIENT, PAD(8)] + padw padw swapdw movup.8 drop + # => [tag, aux, note_type, execution_hint, RECIPIENT, PAD(7)] + + exec.kernel_invocation::create_note_offset + # => [offset, tag, aux, note_type, execution_hint, RECIPIENT, PAD(7)] - exec.memory::create_note_ptr syscall.exec_kernel_proc # => [note_idx, PAD(15)] @@ -95,12 +129,14 @@ end #! note_idx is the index of the note to which the asset is added. #! ASSET can be a fungible or non-fungible asset. export.add_asset_to_note + movup.4 exec.kernel_invocation::add_asset_to_note_offset + # => [offset, note_idx, ASSET] + # pad the stack before the syscall to prevent accidental modification of the deeper stack # elements - push.0.0.0 padw padw swapdw movup.7 swapw movup.4 - # => [note_idx, ASSET, PAD(11)] + push.0.0 movdn.7 movdn.7 padw padw swapdw + # => [offset, note_idx, ASSET, PAD(10)] - exec.memory::add_asset_to_note_ptr syscall.exec_kernel_proc # => [note_idx, ASSET, PAD(11)] diff --git a/miden-lib/src/transaction/mod.rs b/miden-lib/src/transaction/mod.rs index 65c5dd1ee..21cc9e182 100644 --- a/miden-lib/src/transaction/mod.rs +++ b/miden-lib/src/transaction/mod.rs @@ -8,7 +8,7 @@ use miden_objects::{ }, utils::{group_slice_elements, serde::Deserializable}, vm::{AdviceInputs, AdviceMap, Program, ProgramInfo, StackInputs, StackOutputs}, - Digest, Felt, TransactionOutputError, Word, EMPTY_WORD, Hasher, + Digest, Felt, Hasher, TransactionOutputError, Word, EMPTY_WORD, }; use miden_stdlib::StdLibrary; @@ -91,12 +91,13 @@ impl TransactionKernel { ) -> (StackInputs, AdviceInputs) { let account = tx_inputs.account(); - let kernel = Self::kernel().kernel(); + let kernel_lib = Self::kernel(); + let kernel = kernel_lib.kernel(); + // we need to get &[Felt] from &[Digest] - let kernel_procs_as_felts = Digest::digests_as_elements(kernel.proc_hashes().into_iter()) + let kernel_procs_as_felts = Digest::digests_as_elements(kernel.proc_hashes().iter()) .cloned() .collect::>(); - // let aboba = kernel.proc_hashes().iter().flat_map(|digest| digest.as_elements().to_vec()).collect::>(); let kernel_hash = Hasher::hash_elements(&kernel_procs_as_felts); let stack_inputs = TransactionKernel::build_input_stack( @@ -302,5 +303,6 @@ impl TransactionKernel { .expect("failed to load miden-lib") .with_library(kernel_library) .expect("failed to load kernel library (/lib)") + .with_debug_mode(true) } } diff --git a/miden-tx/src/tests/kernel_tests/test_prologue.rs b/miden-tx/src/tests/kernel_tests/test_prologue.rs index cbbd229c6..b3a7f2ffc 100644 --- a/miden-tx/src/tests/kernel_tests/test_prologue.rs +++ b/miden-tx/src/tests/kernel_tests/test_prologue.rs @@ -365,7 +365,7 @@ pub fn test_prologue_create_account() { use.kernel::prologue begin - call.prologue::prepare_transaction + exec.prologue::prepare_transaction end "; diff --git a/miden-tx/src/verifier/mod.rs b/miden-tx/src/verifier/mod.rs index 5006d88ad..bf1485473 100644 --- a/miden-tx/src/verifier/mod.rs +++ b/miden-tx/src/verifier/mod.rs @@ -36,7 +36,7 @@ impl TransactionVerifier { // compute the kernel hash let kernel = self.tx_program_info.kernel(); // we need to get &[Felt] from &[Digest] - let kernel_procs_as_felts = Digest::digests_as_elements(kernel.proc_hashes().into_iter()) + let kernel_procs_as_felts = Digest::digests_as_elements(kernel.proc_hashes().iter()) .cloned() .collect::>(); let kernel_hash = Hasher::hash_elements(&kernel_procs_as_felts); @@ -47,7 +47,7 @@ impl TransactionVerifier { transaction.account_update().init_state_hash(), transaction.input_notes().commitment(), transaction.block_ref(), - (kernel.proc_hashes().len(), kernel_hash) + (kernel.proc_hashes().len(), kernel_hash), ); let stack_outputs = TransactionKernel::build_output_stack( transaction.account_update().final_state_hash(), diff --git a/objects/src/testing/account_code.rs b/objects/src/testing/account_code.rs index 210c9eba4..cfb87f9b5 100644 --- a/objects/src/testing/account_code.rs +++ b/objects/src/testing/account_code.rs @@ -7,16 +7,16 @@ use crate::accounts::AccountCode; const MASTS: [&str; 12] = [ "0xff06b90f849c4b262cbfbea67042c4ea017ea0e9c558848a951d44b23370bec5", "0x8ef0092134469a1330e3c468f57c7f085ce611645d09cc7516c786fefc71d794", - "0x86472c62c0f9d2f93369f793abd66127f9cf4a77d4339dcacfb118aba0cf79b6", - "0xa5e47b6219605992b497ab85404425da4b88ad58789d86ab09bea9ed0ec12897", - "0x56723c7bd5e46ce33f99f256ae1b8f4856600744191f8a18d1c572a925f41ced", - "0x6be2be94390361792f5becf18f3e916fa2458c67b809ad144d8ec5fb144ce9c3", - "0x0f0447bc4eb9a366d8158274427445fcc169949e4ab9092d45ff55c2a7753e2a", - "0x3d77d6c0727fa8c78695123bcd9413e88a5d92e72a60453557fb93dfa575c81a", - "0x383067a3ef06a0fad1f11ab7707c67c286db851cc9edece3ea53a76520a014fa", - "0x59e26d0f909ce76298f12ba6a6a4120b0cf541622128756eb572fd17dbe8732d", - "0xe55e8abaa5a3a8ff89537111b490f22983a7012e65c11ead8478f7a645ba49bd", - "0xad0d0d771f4a301c658c61366b4436a4b45b7e317d0f3ae2c76f37e1f8bd63e6", + "0xa69d960467d9484c79812394587b81b13258a8c76ce7e458229323c734136bf0", + "0x68d503aba05d48bfb8ed4647a54df4e2f4f3f380868300710f991e201407ae36", + "0x18af4d279042d8042eadb854bb58e546bc7546a0b37f34dfd2fc7f995f8f33ce", + "0xaeeed1fe7453d66dd0f175fa1e4a9534eaa9928ee4ba6cc41ea27f41ec619038", + "0x5a600fe00f66dd29083a2985e310da0f85cfc90e5faf4c7661a5c2a91ebcde69", + "0x5c739834a3f5d34fc4c27bc78fd72939a9fa98cce7c5d6bb477624e3431b22ee", + "0xfb2afc65a25b322cdf51bf5450e4c32b93fdde19da351ac8cf28145f19969016", + "0xe1d6c52a75a15cee295e9f787a8bd0c73996b878b746f9c9f7ea9a7af83e6e50", + "0x1798f2959f525fc9b55b0307542600fb987afd965533c993cffa73461e1a1be2", + "0x0651c2b7081d29268e28fe2b99da0cebccd9515d228974a1b3959b12b3a4a448", ]; pub const ACCOUNT_ADD_ASSET_TO_NOTE_MAST_ROOT: &str = MASTS[2];