diff --git a/docs/architecture/transactions/procedures.md b/docs/architecture/transactions/procedures.md
index bde62bf0c..87f807e9c 100644
--- a/docs/architecture/transactions/procedures.md
+++ b/docs/architecture/transactions/procedures.md
@@ -8,73 +8,70 @@ There are user-facing procedures and kernel procedures. Users don't directly inv
These procedures can be used to create smart contract/account code, note scripts, or account scripts. They basically serve as an API for the underlying kernel procedures. If a procedure can be called in the current context, an `exec` is sufficient. Otherwise the context procedures must be invoked by `call`. Users never need to invoke `syscall` procedures themselves.
-!!! tip
- - If capitalized, a variable representing a `word`, e.g., `ACCT_HASH` consists of four `felts`. If lowercase, the variable is represented by a single `felt`.
+!!! tip - If capitalized, a variable representing a `word`, e.g., `ACCT_HASH` consists of four `felts`. If lowercase, the variable is represented by a single `felt`.
### Account
-To import the account procedures, set `use.miden::account` at the beginning of the file.
+To import the account procedures, set `use.miden::account` at the beginning of the file.
Any procedure that changes the account state must be invoked in the account context and not by note or transaction scripts. All procedures invoke `syscall` to the kernel API and some are restricted by the kernel procedure `exec.authenticate_account_origin`, which fails if the parent context is not the executing account.
-| Procedure name | Stack | Output | Context | Description |
-|---------------------------|------------|--------------|---------|---------------------------------------------------------------------|
-| `get_id` | `[]` | `[acct_id]` | account, note |
|
-| `get_nonce` | `[]` | `[nonce]` | account, note | - Returns the account nonce.
|
-| `get_initial_hash` | `[]` | `[H]` | account, note | - Returns the initial account hash.
|
-| `get_current_hash` | `[]` | `[ACCT_HASH]`| account, note | - Computes and returns the account hash from account data stored in memory.
-| `incr_nonce` | `[value]` | `[]` | account | - Increments the account nonce by the provided `value` which can be at most `2^32 - 1` otherwise the procedure panics.
|
-| `get_item` | `[index]` | `[VALUE]` | account, note | - Gets an item `VALUE` by `index` from the account storage.
- Panics if the index is out of bounds.
|
-| `set_item` | `[index, V']` | `[R', V]` | account | - Sets an index/value pair in the account storage.
- Panics if the index is out of bounds. `R` is the new storage root.
|
-| `set_code` | `[CODE_ROOT]`| `[]` | account | - Sets the code (`CODE_ROOT`) of the account the transaction is being executed against.
- This procedure can only be executed on regular accounts with updatable code. Otherwise, the procedure fails.
|
-| `get_balance` | `[faucet_id]`| `[balance]`| account, note | - Returns the `balance` of a fungible asset associated with a `faucet_id`.
- Panics if the asset is not a fungible asset.
|
-| `has_non_fungible_asset` | `[ASSET]` | `[has_asset]`| account, note | - Returns a boolean `has_asset` indicating whether the non-fungible asset is present in the vault.
- Panics if the `ASSET` is a fungible asset.
|
-| `add_asset` | `[ASSET]` | `[ASSET']` | account | - Adds the specified asset `ASSET` to the vault. Panics under various conditions.
- If `ASSET` is a non-fungible asset, then `ASSET'` is the same as `ASSET`.
- If `ASSET` is a fungible asset, then `ASSET'` is the total fungible asset in the account vault after `ASSET` was added to it.
|
-| `remove_asset` | `[ASSET]` | `[ASSET]` | account | - Removes the specified `ASSET` from the vault.
- Panics under various conditions.
|
-| `get_vault_commitment` | `[]` | `[COM]` | account, note | - Returns a commitment `COM` to the account vault.
|
+| Procedure name | Stack | Output | Context | Description |
+| ------------------------ | ------------------- | ------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `get_id` | `[]` | `[acct_id]` | account, note | |
+| `get_nonce` | `[]` | `[nonce]` | account, note | - Returns the account nonce.
|
+| `get_initial_hash` | `[]` | `[H]` | account, note | - Returns the initial account hash.
|
+| `get_current_hash` | `[]` | `[ACCT_HASH]` | account, note | - Computes and returns the account hash from account data stored in memory.
|
+| `incr_nonce` | `[value]` | `[]` | account | - Increments the account nonce by the provided `value` which can be at most `2^32 - 1` otherwise the procedure panics.
|
+| `get_item` | `[index]` | `[VALUE]` | account, note | - Gets an item `VALUE` by `index` from the account storage.
- Panics if the index is out of bounds.
|
+| `set_item` | `[index, V']` | `[R', V]` | account | - Sets an index/value pair in the account storage.
- Panics if the index is out of bounds. `R` is the new storage root.
|
+| `set_code` | `[CODE_COMMITMENT]` | `[]` | account | - Sets the code (`CODE_COMMITMENT`) of the account the transaction is being executed against.
- This procedure can only be executed on regular accounts with updatable code. Otherwise, the procedure fails.
|
+| `get_balance` | `[faucet_id]` | `[balance]` | account, note | - Returns the `balance` of a fungible asset associated with a `faucet_id`.
- Panics if the asset is not a fungible asset.
|
+| `has_non_fungible_asset` | `[ASSET]` | `[has_asset]` | account, note | - Returns a boolean `has_asset` indicating whether the non-fungible asset is present in the vault.
- Panics if the `ASSET` is a fungible asset.
|
+| `add_asset` | `[ASSET]` | `[ASSET']` | account | - Adds the specified asset `ASSET` to the vault. Panics under various conditions.
- If `ASSET` is a non-fungible asset, then `ASSET'` is the same as `ASSET`.
- If `ASSET` is a fungible asset, then `ASSET'` is the total fungible asset in the account vault after `ASSET` was added to it.
|
+| `remove_asset` | `[ASSET]` | `[ASSET]` | account | - Removes the specified `ASSET` from the vault.
- Panics under various conditions.
|
+| `get_vault_commitment` | `[]` | `[COM]` | account, note | - Returns a commitment `COM` to the account vault.
|
### Note
To import the note procedures, set `use.miden::note` at the beginning of the file. All procedures are restricted to the note context.
-| Procedure name | Inputs | Outputs | Context | Description |
-|--------------------------|---------------------|-----------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
-| `get_assets` | `[dest_ptr]` | `[num_assets, dest_ptr]` | note | - Writes the assets of the currently executing note into memory starting at the specified address `dest_ptr `.
- `num_assets` is the number of assets in the currently executing note.
|
-| `get_inputs` | `[dest_ptr]` | `[dest_ptr]` | note | - Writes the inputs of the currently executed note into memory starting at the specified address, `dest_ptr`.
|
-| `get_sender` | `[]` | `[sender]` | note | - Returns the `sender` of the note currently being processed. Panics if a note is not being processed.
|
-| `compute_inputs_hash` | `[inputs_ptr, num_inputs]` | `[HASH]` | note | - Computes hash of note inputs starting at the specified memory address.
|
-
+| Procedure name | Inputs | Outputs | Context | Description |
+| --------------------- | -------------------------- | ------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `get_assets` | `[dest_ptr]` | `[num_assets, dest_ptr]` | note | - Writes the assets of the currently executing note into memory starting at the specified address `dest_ptr `.
- `num_assets` is the number of assets in the currently executing note.
|
+| `get_inputs` | `[dest_ptr]` | `[dest_ptr]` | note | - Writes the inputs of the currently executed note into memory starting at the specified address, `dest_ptr`.
|
+| `get_sender` | `[]` | `[sender]` | note | - Returns the `sender` of the note currently being processed. Panics if a note is not being processed.
|
+| `compute_inputs_hash` | `[inputs_ptr, num_inputs]` | `[HASH]` | note | - Computes hash of note inputs starting at the specified memory address.
|
### Tx
-To import the transaction procedures set `use.miden::tx` at the beginning of the file. Only the `create_note` procedure is restricted to the account context.
-| Procedure name | Inputs | Outputs | Context | Description |
-|--------------------------|------------------|-------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| `get_block_number` | `[]` | `[num]` | account, note | - Returns the block number `num` of the last known block at the time of transaction execution. |
-| `get_block_hash` | `[]` | `[H]` | account, note |
- Returns the block hash `H` of the last known block at the time of transaction execution.
|
-| `get_input_notes_hash` | `[]` | `[COM]` | account, note | - Returns the input notes hash `COM`.
- This is computed as a sequential hash of (nullifier, empty_word_or_note_hash) tuples over all input notes. The `empty_word_or_notes_hash` functions as a flag, if the value is set to zero, then the notes are authenticated by the transaction kernel. If the value is non-zero, then note authentication will 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.
|
-| `get_output_notes_hash` | `[0, 0, 0, 0]` | `[COM]` | account, note | - Returns the output notes hash `COM`.
- This is computed as a sequential hash of (note_id, note_metadata) tuples over all output notes.
|
-| `create_note` | `[ASSET, tag, RECIPIENT]` | `[ptr]` | account | - Creates a new note and returns a pointer to the memory address at which the note is stored.
- `ASSET` is the asset to be included in the note.
- `tag` is the tag to be included in the note. `RECIPIENT` is the recipient of the note.
- `ptr` is the pointer to the memory address at which the note is stored.
|
+To import the transaction procedures set `use.miden::tx` at the beginning of the file. Only the `create_note` procedure is restricted to the account context.
+| Procedure name | Inputs | Outputs | Context | Description |
+| ----------------------- | ------------------------- | ------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `get_block_number` | `[]` | `[num]` | account, note | - Returns the block number `num` of the last known block at the time of transaction execution. |
+| `get_block_hash` | `[]` | `[H]` | account, note |
- Returns the block hash `H` of the last known block at the time of transaction execution.
|
+| `get_input_notes_hash` | `[]` | `[COM]` | account, note | - Returns the input notes hash `COM`.
- This is computed as a sequential hash of (nullifier, empty_word_or_note_hash) tuples over all input notes. The `empty_word_or_notes_hash` functions as a flag, if the value is set to zero, then the notes are authenticated by the transaction kernel. If the value is non-zero, then note authentication will 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.
|
+| `get_output_notes_hash` | `[0, 0, 0, 0]` | `[COM]` | account, note | - Returns the output notes hash `COM`.
- This is computed as a sequential hash of (note_id, note_metadata) tuples over all output notes.
|
+| `create_note` | `[ASSET, tag, RECIPIENT]` | `[ptr]` | account | - Creates a new note and returns a pointer to the memory address at which the note is stored.
- `ASSET` is the asset to be included in the note.
- `tag` is the tag to be included in the note. `RECIPIENT` is the recipient of the note.
- `ptr` is the pointer to the memory address at which the note is stored.
|
### Asset
+
To import the asset procedures set `use.miden::asset` at the beginning of the file. These procedures can only be called by faucet accounts.
-| Procedure name | Stack | Output | Context | Description |
-|------------------------------|---------------------|-----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| `build_fungible_asset` | `[faucet_id, amount]` | `[ASSET]` | faucet | - Builds a fungible asset `ASSET` for the specified fungible faucet `faucet_id`, and `amount` of asset to create.
|
-| `create_fungible_asset` | `[amount]` | `[ASSET]` | faucet | - Creates a fungible asset `ASSET` for the faucet the transaction is being executed against and `amount` of the asset to create.
|
-| `build_non_fungible_asset` | `[faucet_id, DATA_HASH]` | `[ASSET]` | faucet | - Builds a non-fungible asset `ASSET` for the specified non-fungible faucet.
- `faucet_id` is the faucet to create the asset for.
- `DATA_HASH` is the data hash of the non-fungible asset to build.
|
-| `create_non_fungible_asset` | `[DATA_HASH]` | `[ASSET]` | faucet | - Creates a non-fungible asset `ASSET` for the faucet the transaction is being executed against.
- `DATA_HASH` is the data hash of the non-fungible asset to create.
|
+| Procedure name | Stack | Output | Context | Description |
+| --------------------------- | ------------------------ | --------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `build_fungible_asset` | `[faucet_id, amount]` | `[ASSET]` | faucet | - Builds a fungible asset `ASSET` for the specified fungible faucet `faucet_id`, and `amount` of asset to create.
|
+| `create_fungible_asset` | `[amount]` | `[ASSET]` | faucet | - Creates a fungible asset `ASSET` for the faucet the transaction is being executed against and `amount` of the asset to create.
|
+| `build_non_fungible_asset` | `[faucet_id, DATA_HASH]` | `[ASSET]` | faucet | - Builds a non-fungible asset `ASSET` for the specified non-fungible faucet.
- `faucet_id` is the faucet to create the asset for.
- `DATA_HASH` is the data hash of the non-fungible asset to build.
|
+| `create_non_fungible_asset` | `[DATA_HASH]` | `[ASSET]` | faucet | - Creates a non-fungible asset `ASSET` for the faucet the transaction is being executed against.
- `DATA_HASH` is the data hash of the non-fungible asset to create.
|
### Faucet
To import the faucet procedures, set `use.miden::faucet` at the beginning of the file.
-| Procedure name | Stack | Outputs | Context | Description |
-|--------------------------|------------|-------------------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| `mint` | `[ASSET]` | `[ASSET]` | faucet | - Mint an asset `ASSET` from the faucet the transaction is being executed against.
- Panics under various conditions.
|
-| `burn` | `[ASSET]` | `[ASSET]` | faucet | - Burn an asset `ASSET` from the faucet the transaction is being executed against.
- Panics under various conditions.
|
-| `get_total_issuance` | `[]` | `[total_issuance]`| faucet | - Returns the `total_issuance` of the fungible faucet the transaction is being executed against.
- Panics if the transaction is not being executed against a fungible faucet.
|
-
-
+| Procedure name | Stack | Outputs | Context | Description |
+| -------------------- | --------- | ------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `mint` | `[ASSET]` | `[ASSET]` | faucet | - Mint an asset `ASSET` from the faucet the transaction is being executed against.
- Panics under various conditions.
|
+| `burn` | `[ASSET]` | `[ASSET]` | faucet | - Burn an asset `ASSET` from the faucet the transaction is being executed against.
- Panics under various conditions.
|
+| `get_total_issuance` | `[]` | `[total_issuance]` | faucet | - Returns the `total_issuance` of the fungible faucet the transaction is being executed against.
- Panics if the transaction is not being executed against a fungible faucet.
|
diff --git a/miden-lib/asm/kernels/transaction/api.masm b/miden-lib/asm/kernels/transaction/api.masm
index fa2932cf6..f62d5844b 100644
--- a/miden-lib/asm/kernels/transaction/api.masm
+++ b/miden-lib/asm/kernels/transaction/api.masm
@@ -261,18 +261,18 @@ 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_ROOT]
+#! Stack: [CODE_COMMITMENT]
#! Output: [0, 0, 0, 0]
#!
-#! - CODE_ROOT is the hash of the code to set.
+#! - CODE_COMMITMENT is the hash of the code to set.
export.set_account_code
# authenticate that the procedure invocation originates from the account context
exec.authenticate_account_origin
- # => [CODE_ROOT]
+ # => [CODE_COMMITMENT]
# arrange stack
padw swapw
- # => [CODE_ROOT, 0, 0, 0, 0]
+ # => [CODE_COMMITMENT, 0, 0, 0, 0]
# set the account code
exec.account::set_code
diff --git a/miden-lib/asm/miden/account.masm b/miden-lib/asm/miden/account.masm
index 5020ef9a1..200f72c69 100644
--- a/miden-lib/asm/miden/account.masm
+++ b/miden-lib/asm/miden/account.masm
@@ -143,10 +143,10 @@ 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_ROOT]
+#! Stack: [CODE_COMMITMENT]
#! Output: []
#!
-#! - CODE_ROOT is the hash of the code to set.
+#! - CODE_COMMITMENT is the hash of the code to set.
export.set_code
syscall.set_account_code
# => [0, 0, 0, 0]
diff --git a/miden-lib/asm/miden/kernels/tx/account.masm b/miden-lib/asm/miden/kernels/tx/account.masm
index fd0d2b091..399308d06 100644
--- a/miden-lib/asm/miden/kernels/tx/account.masm
+++ b/miden-lib/asm/miden/kernels/tx/account.masm
@@ -299,21 +299,21 @@ 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_ROOT]
+#! Stack: [CODE_COMMITMENT]
#! Output: []
#!
-#! - CODE_ROOT is the hash of the code to set.
+#! - CODE_COMMITMENT is the hash of the code to set.
export.set_code
# get the account id
exec.memory::get_acct_id
- # => [acct_id, CODE_ROOT]
+ # => [acct_id, CODE_COMMITMENT]
# assert the account is an updatable regular account
exec.is_updatable_account assert.err=ERR_ACCOUNT_SET_CODE_ACCOUNT_MUST_BE_UPDATABLE
- # => [CODE_ROOT]
+ # => [CODE_COMMITMENT]
- # set the code root
- exec.memory::set_new_acct_code_root dropw
+ # set the code commitment
+ exec.memory::set_new_acct_code_commitment dropw
# => []
end
@@ -515,7 +515,7 @@ end
#! Validates that the account seed, provided via the advice map, satisfies the seed requirements.
#!
#! Validation is performed via the following steps:
-#! 1. compute the hash of (SEED, CODE_ROOT, STORAGE_ROOT, 0, 0, 0, 0)
+#! 1. compute the hash of (SEED, CODE_commitment, STORAGE_ROOT, 0, 0, 0, 0)
#! 2. Assert the least significant element of the digest is equal to the account id of the account
#! the transaction is being executed against.
#! 3. Assert the most significant element has sufficient proof of work (trailing zeros) for the account
@@ -528,11 +528,11 @@ export.validate_seed
padw exec.memory::get_acct_id push.0.0.0 adv.push_mapval adv_loadw
# => [SEED, 0, 0, 0, 0]
- # populate last four elements of the hasher rate with the code root
- exec.memory::get_acct_code_root
- # => [CODE_ROOT, SEED, 0, 0, 0, 0]
+ # populate last four elements of the hasher rate with the code commitment
+ exec.memory::get_acct_code_commitment
+ # => [CODE_COMMITMENT, SEED, 0, 0, 0, 0]
- # perform first permutation of seed and code_root (from advice stack) perm(seed, code_root)
+ # perform first permutation of seed and code_commitment (from advice stack) perm(seed, code_commitment)
hperm
# => [RATE, RATE, PERM]
diff --git a/miden-lib/asm/miden/kernels/tx/epilogue.masm b/miden-lib/asm/miden/kernels/tx/epilogue.masm
index f41e43eab..f4400fb7e 100644
--- a/miden-lib/asm/miden/kernels/tx/epilogue.masm
+++ b/miden-lib/asm/miden/kernels/tx/epilogue.masm
@@ -144,20 +144,20 @@ end
# ACCOUNT CODE UPDATE
# =================================================================================================
-#! Updates the account code root if the account code has changed. `NEW_ACCT_CODE_ROOT` is set to
-#! the initial account code root in the prologue and as such this procedure will not result in a
-#! change to the account code root if the `account::set_code` procedure has not been invoked in
+#! Updates the account code commitment if the account code has changed. `NEW_ACCT_CODE_COMMITMENT` is set to
+#! the initial account code commitment in the prologue and as such this procedure will not result in a
+#! change to the account code commitment if the `account::set_code` procedure has not been invoked in
#! this transaction.
#!
#! Stack: []
#! Output: []
proc.update_account_code
- # check if the account code root has been updated
- exec.memory::get_new_acct_code_root
- # => [NEW_ACCT_CODE_ROOT]
+ # check if the account code commitment has been updated
+ exec.memory::get_new_acct_code_commitment
+ # => [NEW_ACCT_CODE_COMMITMENT]
- # set the account code root to the new account code root (may not have changed)
- exec.memory::set_acct_code_root dropw
+ # set the account code commitment to the new account code commitment (may not have changed)
+ exec.memory::set_acct_code_commitment dropw
# => []
end
diff --git a/miden-lib/asm/miden/kernels/tx/memory.masm b/miden-lib/asm/miden/kernels/tx/memory.masm
index 164dbebba..13bbed135 100644
--- a/miden-lib/asm/miden/kernels/tx/memory.masm
+++ b/miden-lib/asm/miden/kernels/tx/memory.masm
@@ -108,11 +108,11 @@ const.ACCT_VAULT_ROOT_PTR=401
# The memory address at which the account storage root is stored
const.ACCT_STORAGE_ROOT_PTR=402
-# The memory address at which the account code root is stored
-const.ACCT_CODE_ROOT_PTR=403
+# The memory address at which the account code commitment is stored
+const.ACCT_CODE_COMMITMENT_PTR=403
-# The memory address at which the new account code root is stored
-const.ACCT_NEW_CODE_ROOT_PTR=404
+# The memory address at which the new account code commitment is stored
+const.ACCT_NEW_CODE_COMMITMENT_PTR=404
# The memory offset at which the account data section ends (exclusive)
const.ACCT_CORE_DATA_SECTION_END_OFFSET=404
@@ -658,50 +658,50 @@ export.get_account_procedures_section_offset
push.ACCT_PROCEDURES_SECTION_OFFSET
end
-#! Sets the code root of the account.
+#! Sets the code commitment of the account.
#!
-#! Stack: [CODE_ROOT]
-#! Output: [CODE_ROOT]
+#! Stack: [CODE_COMMITMENT]
+#! Output: [CODE_COMMITMENT]
#!
#! Where:
-#! - CODE_ROOT is the code root to be set.
-export.set_acct_code_root
- push.ACCT_CODE_ROOT_PTR
+#! - CODE_COMMITMENT is the code commitment to be set.
+export.set_acct_code_commitment
+ push.ACCT_CODE_COMMITMENT_PTR
mem_storew
end
-#! Returns the code root of the account.
+#! Returns the code commitment of the account.
#!
#! Stack: []
-#! Output: [CODE_ROOT]
+#! Output: [CODE_COMMITMENT]
#!
#! Where:
-#! - CODE_ROOT is the code root of the account.
-export.get_acct_code_root
- padw push.ACCT_CODE_ROOT_PTR mem_loadw
+#! - CODE_COMMITMENT is the code commitment of the account.
+export.get_acct_code_commitment
+ padw push.ACCT_CODE_COMMITMENT_PTR mem_loadw
end
-#! Stores the new account code root in memory.
+#! Stores the new account code commitment in memory.
#!
-#! Stack: [CODE_ROOT]
-#! Output: [CODE_ROOT]
+#! Stack: [CODE_COMMITMENT]
+#! Output: [CODE_COMMITMENT]
#!
#! Where:
-#! - CODE_ROOT is the new account code root.
-export.set_new_acct_code_root
- push.ACCT_NEW_CODE_ROOT_PTR
+#! - CODE_COMMITMENT is the new account code commitment.
+export.set_new_acct_code_commitment
+ push.ACCT_NEW_CODE_COMMITMENT_PTR
mem_storew
end
-#! Returns the new account code root.
+#! Returns the new account code commitment.
#!
#! Stack: []
-#! Output: [CODE_ROOT]
+#! Output: [CODE_COMMITMENT]
#!
#! Where:
-#! - CODE_ROOT is the new account code root.
-export.get_new_acct_code_root
- padw push.ACCT_NEW_CODE_ROOT_PTR mem_loadw
+#! - CODE_COMMITMENT is the new account code commitment.
+export.get_new_acct_code_commitment
+ padw push.ACCT_NEW_CODE_COMMITMENT_PTR mem_loadw
end
#! Returns the account storage root.
diff --git a/miden-lib/asm/miden/kernels/tx/prologue.masm b/miden-lib/asm/miden/kernels/tx/prologue.masm
index e0f56cf03..949515e48 100644
--- a/miden-lib/asm/miden/kernels/tx/prologue.masm
+++ b/miden-lib/asm/miden/kernels/tx/prologue.masm
@@ -384,50 +384,50 @@ proc.validate_new_account
# => []
end
-#! Validates that account procedures match account code root.
+#! Validates that account procedures match account code commitment.
#!
#! This is achieved by reading account procedures from AdviceMap and sequentially hashing them
-#! before comparing the final hash to the account code root. This procedure also populates memory
+#! before comparing the final hash to the account code commitment. This procedure also populates memory
#! with these account procedures.
#!
#! Stack: []
#! Output: []
proc.validate_account_procedures
- # get account code root to query elements from AdviceMap
- exec.memory::get_acct_code_root
- # => [ACCT_CODE_ROOT]
+ # get account code commitment to query elements from AdviceMap
+ exec.memory::get_acct_code_commitment
+ # => [ACCT_CODE_COMMITMENT]
# query elements from AdviceMap and get num of procedures to pipe
adv.push_mapval adv_push.1
- # => [len, ACCT_CODE_ROOT]
+ # => [len, ACCT_CODE_COMMITMENT]
# get counter and account procedures memory location
push.0 exec.memory::get_account_procedures_section_offset
- # => [location, counter, len, ACCT_CODE_ROOT]
+ # => [location, counter, len, ACCT_CODE_COMMITMENT]
# prepare stack for looping
padw padw padw push.1
- # => [PAD, PAD, PAD, 1, location, counter, len, ACCT_CODE_ROOT]
+ # => [PAD, PAD, PAD, 1, location, counter, len, ACCT_CODE_COMMITMENT]
while.true
# pipe elements from advice map to stack and memory and hash them
adv_pipe hperm
- # => [HASH, HASH, HASH, location, counter, len, ACCT_CODE_ROOT]
+ # => [HASH, HASH, HASH, location, counter, len, ACCT_CODE_COMMITMENT]
# check if all account procedures have been piped
movup.13 add.1 dup movdn.14 dup.15 neq
- # => [should_loop, HASH, HASH, HASH, location, counter, len, ACCT_CODE_ROOT]
+ # => [should_loop, HASH, HASH, HASH, location, counter, len, ACCT_CODE_COMMITMENT]
end
# keep relevant hash
exec.native::state_to_digest
- # => [HASH, location, counter, len, ACCT_CODE_ROOT]
+ # => [HASH, location, counter, len, ACCT_CODE_COMMITMENT]
# drop memory location, counter and number of procedures
movup.4 movup.5 movup.6 drop drop drop
- # => [HASH, ACCT_CODE_ROOT]
+ # => [HASH, ACCT_CODE_COMMITMENT]
- # verify hashed account procedures match account code root
+ # verify hashed account procedures match account code commitment
assert_eqw
# => []
end
@@ -444,7 +444,7 @@ end
#! and the account nonce is not zero
#!
#! Stack: []
-#! Advice stack: [[account_id, 0, 0, account_nonce], ACCOUNT_VAULT_ROOT, ACCOUNT_STORAGE_ROOT, ACCOUNT_CODE_ROOT]
+#! Advice stack: [[account_id, 0, 0, account_nonce], ACCOUNT_VAULT_ROOT, ACCOUNT_STORAGE_ROOT, ACCOUNT_CODE_COMMITMENT]
#! Output: []
#!
#! Where:
@@ -452,7 +452,7 @@ end
#! - account_nonce, account's nonce.
#! - ACCOUNT_VAULT_ROOT, account's vault root.
#! - ACCOUNT_STORAGE_ROOT, account's storage root.
-#! - ACCOUNT_CODE_ROOT, account's code root.
+#! - ACCOUNT_CODE_COMMITMENT, account's code commitment.
proc.process_account_data
# Copy the account data from the advice stack to memory and hash it
# ---------------------------------------------------------------------------------------------
@@ -520,10 +520,10 @@ proc.process_account_data
exec.memory::set_init_nonce
# => []
- # set the new account code root to the initial account code root this is used for managing
- # code root updates, validates and stores account procedures in memory.
- exec.memory::get_acct_code_root
- exec.memory::set_new_acct_code_root dropw
+ # set the new account code commitment to the initial account code commitment this is used for managing
+ # code commitment updates, validates and stores account procedures in memory.
+ exec.memory::get_acct_code_commitment
+ exec.memory::set_new_acct_code_commitment dropw
exec.validate_account_procedures
# => []
@@ -1089,7 +1089,7 @@ end
#! [account_id, 0, 0, account_nonce],
#! ACCOUNT_VAULT_ROOT,
#! ACCOUNT_STORAGE_ROOT,
-#! ACCOUNT_CODE_ROOT,
+#! ACCOUNT_CODE_COMMITMENT,
#! number_of_input_notes,
#! TX_SCRIPT_ROOT,
#! ]
@@ -1117,7 +1117,7 @@ end
#! - account_nonce, account's nonce.
#! - ACCOUNT_VAULT_ROOT, account's vault root.
#! - ACCOUNT_STORAGE_ROOT, account's storage root.
-#! - ACCOUNT_CODE_ROOT, account's code root.
+#! - ACCOUNT_CODE_COMMITMENT, account's code commitment.
#! - number_of_input_notes, number of input notes.
#! - TX_SCRIPT_ROOT, the transaction's script root.
#! - MMR_PEAKS, is the MMR peak data, see process_chain_data
diff --git a/miden-lib/src/transaction/inputs.rs b/miden-lib/src/transaction/inputs.rs
index f50a17290..131dc768e 100644
--- a/miden-lib/src/transaction/inputs.rs
+++ b/miden-lib/src/transaction/inputs.rs
@@ -116,7 +116,7 @@ fn extend_advice_inputs(
/// [account_id, 0, 0, account_nonce],
/// ACCOUNT_VAULT_ROOT,
/// ACCOUNT_STORAGE_ROOT,
-/// ACCOUNT_CODE_ROOT,
+/// ACCOUNT_CODE_COMMITMENT,
/// number_of_input_notes,
/// TX_SCRIPT_ROOT,
/// ]
diff --git a/miden-lib/src/transaction/outputs.rs b/miden-lib/src/transaction/outputs.rs
index e0ed52045..79f33767c 100644
--- a/miden-lib/src/transaction/outputs.rs
+++ b/miden-lib/src/transaction/outputs.rs
@@ -21,7 +21,7 @@ pub const FINAL_ACCOUNT_HASH_WORD_IDX: usize = 1;
// ================================================================================================
/// Parses the stub account data returned by the VM into individual account component commitments.
-/// Returns a tuple of account ID, vault root, storage root, code root, and nonce.
+/// Returns a tuple of account ID, vault root, storage root, code commitment, and nonce.
pub fn parse_final_account_stub(elements: &[Word]) -> Result {
if elements.len() != ACCT_DATA_MEM_SIZE {
return Err(AccountError::StubDataIncorrectLength(elements.len(), ACCT_DATA_MEM_SIZE));
@@ -31,7 +31,7 @@ pub fn parse_final_account_stub(elements: &[Word]) -> Result(
- account_code_root: Digest,
+ account_code_commitment: Digest,
adv_provider: &A,
) -> Result {
// get the account procedures from the advice_map
- let procs = adv_provider.get_mapped_values(&account_code_root).ok_or_else(|| {
+ let procs = adv_provider.get_mapped_values(&account_code_commitment).ok_or_else(|| {
TransactionHostError::AccountProcedureIndexMapError(
"Failed to get mapped values from the AdviceProvider".to_string(),
)
diff --git a/miden-tx/src/testing/account_procs.rs b/miden-tx/src/testing/account_procs.rs
index 1dd5ec518..381d854a7 100644
--- a/miden-tx/src/testing/account_procs.rs
+++ b/miden-tx/src/testing/account_procs.rs
@@ -12,9 +12,9 @@ pub struct AccountProcedureIndexMap(BTreeMap);
impl AccountProcedureIndexMap {
/// Returns a new [AccountProcedureIndexMap] instantiated with account procedures present in
/// the provided advice provider.
- pub fn new(account_code_root: Digest, adv_provider: &A) -> Self {
+ pub fn new(account_code_commitment: Digest, adv_provider: &A) -> Self {
// get the account procedures from the advice_map
- let procs = adv_provider.get_mapped_values(&account_code_root).unwrap();
+ let procs = adv_provider.get_mapped_values(&account_code_commitment).unwrap();
let mut result = BTreeMap::new();
diff --git a/miden-tx/src/tests/kernel_tests/test_account.rs b/miden-tx/src/tests/kernel_tests/test_account.rs
index a2e9d565a..50cb441ba 100644
--- a/miden-tx/src/tests/kernel_tests/test_account.rs
+++ b/miden-tx/src/tests/kernel_tests/test_account.rs
@@ -41,13 +41,13 @@ pub fn test_set_code_is_not_immediate() {
assert_eq!(
read_root_mem_value(&process, ACCT_CODE_COMMITMENT_PTR),
tx_context.account().code().commitment().as_elements(),
- "the code root must not change immediatelly",
+ "the code commitment must not change immediatelly",
);
assert_eq!(
read_root_mem_value(&process, ACCT_NEW_CODE_COMMITMENT_PTR),
[ONE, Felt::new(2), Felt::new(3), Felt::new(4)],
- "the code root must be cached",
+ "the code commitment must be cached",
);
}
@@ -88,7 +88,7 @@ pub fn test_set_code_succeeds() {
assert_eq!(
read_root_mem_value(&process, ACCT_CODE_COMMITMENT_PTR),
[ZERO, ONE, Felt::new(2), Felt::new(3)],
- "the code root must change after the epilogue",
+ "the code commitment must change after the epilogue",
);
}
diff --git a/miden-tx/tests/integration/wallet/mod.rs b/miden-tx/tests/integration/wallet/mod.rs
index 49ec96245..0a19a13b6 100644
--- a/miden-tx/tests/integration/wallet/mod.rs
+++ b/miden-tx/tests/integration/wallet/mod.rs
@@ -223,14 +223,14 @@ fn wallet_creation() {
// sender_account_id not relevant here, just to create a default account code
let sender_account_id = AccountId::try_from(ACCOUNT_ID_SENDER).unwrap();
- let expected_code_root =
+ let expected_code_commitment =
get_account_with_default_account_code(sender_account_id, pub_key.into(), None)
.code()
.commitment()
.clone();
assert!(wallet.is_regular_account());
- assert_eq!(wallet.code().commitment().clone(), expected_code_root);
+ assert_eq!(wallet.code().commitment().clone(), expected_code_commitment);
let pub_key_word: Word = pub_key.into();
assert_eq!(wallet.storage().get_item(0).as_elements(), pub_key_word);
}
diff --git a/objects/src/accounts/account_id.rs b/objects/src/accounts/account_id.rs
index ed9a93cc0..4f9df5e7c 100644
--- a/objects/src/accounts/account_id.rs
+++ b/objects/src/accounts/account_id.rs
@@ -126,15 +126,15 @@ impl AccountId {
// CONSTRUCTORS
// --------------------------------------------------------------------------------------------
- /// Returns a new account ID derived from the specified seed, code root and storage root.
+ /// Returns a new account ID derived from the specified seed, code commitment and storage root.
///
- /// The account ID is computed by hashing the seed, code root and storage root and using 1
+ /// The account ID is computed by hashing the seed, code commitment and storage root and using 1
/// element of the resulting digest to form the ID. Specifically we take element 0. We also
/// require that the last element of the seed digest has at least `23` trailing zeros if it
/// is a regular account, or `31` trailing zeros if it is a faucet account.
///
/// The seed digest is computed using a sequential hash over
- /// hash(SEED, CODE_ROOT, STORAGE_ROOT, ZERO). This takes two permutations.
+ /// hash(SEED, CODE_COMMITMENT, STORAGE_ROOT, ZERO). This takes two permutations.
///
/// # Errors
/// Returns an error if the resulting account ID does not comply with account ID rules:
@@ -143,8 +143,12 @@ impl AccountId {
/// - the last element of the seed digest has at least `23` trailing zeros for regular
/// accounts.
/// - the last element of the seed digest has at least `31` trailing zeros for faucet accounts.
- pub fn new(seed: Word, code_root: Digest, storage_root: Digest) -> Result {
- let seed_digest = compute_digest(seed, code_root, storage_root);
+ pub fn new(
+ seed: Word,
+ code_commitment: Digest,
+ storage_root: Digest,
+ ) -> Result {
+ let seed_digest = compute_digest(seed, code_commitment, storage_root);
Self::validate_seed_digest(&seed_digest)?;
seed_digest[0].try_into()
@@ -161,19 +165,19 @@ impl AccountId {
/// Creates a new dummy [AccountId] for testing purposes.
#[cfg(any(feature = "testing", test))]
pub fn new_dummy(init_seed: [u8; 32], account_type: AccountType) -> Self {
- let code_root = Digest::default();
+ let code_commitment = Digest::default();
let storage_root = Digest::default();
let seed = get_account_seed(
init_seed,
account_type,
AccountStorageType::OnChain,
- code_root,
+ code_commitment,
storage_root,
)
.unwrap();
- Self::new(seed, code_root, storage_root).unwrap()
+ Self::new(seed, code_commitment, storage_root).unwrap()
}
// PUBLIC ACCESSORS
@@ -218,10 +222,10 @@ impl AccountId {
init_seed: [u8; 32],
account_type: AccountType,
storage_type: AccountStorageType,
- code_root: Digest,
+ code_commitment: Digest,
storage_root: Digest,
) -> Result {
- get_account_seed(init_seed, account_type, storage_type, code_root, storage_root)
+ get_account_seed(init_seed, account_type, storage_type, code_commitment, storage_root)
}
/// Creates an Account Id from a hex string. Assumes the string starts with "0x" and
@@ -399,12 +403,12 @@ fn parse_felt(bytes: &[u8]) -> Result {
Felt::try_from(bytes).map_err(|err| AccountError::AccountIdInvalidFieldElement(err.to_string()))
}
-/// Returns the digest of two hashing permutations over the seed, code root, storage root and
+/// Returns the digest of two hashing permutations over the seed, code commitment, storage root and
/// padding.
-pub(super) fn compute_digest(seed: Word, code_root: Digest, storage_root: Digest) -> Digest {
+pub(super) fn compute_digest(seed: Word, code_commitment: Digest, storage_root: Digest) -> Digest {
let mut elements = Vec::with_capacity(16);
elements.extend(seed);
- elements.extend(*code_root);
+ elements.extend(*code_commitment);
elements.extend(*storage_root);
elements.resize(16, ZERO);
Hasher::hash_elements(&elements)
diff --git a/objects/src/accounts/seed.rs b/objects/src/accounts/seed.rs
index bdacc1634..eaa465617 100644
--- a/objects/src/accounts/seed.rs
+++ b/objects/src/accounts/seed.rs
@@ -23,7 +23,7 @@ pub fn get_account_seed(
init_seed: [u8; 32],
account_type: AccountType,
storage_type: AccountStorageType,
- code_root: Digest,
+ code_commitment: Digest,
storage_root: Digest,
) -> Result {
let thread_count = thread::available_parallelism().map_or(1, |v| v.get());
@@ -43,7 +43,7 @@ pub fn get_account_seed(
init_seed,
account_type,
storage_type,
- code_root,
+ code_commitment,
storage_root,
)
});
@@ -73,7 +73,7 @@ pub fn get_account_seed_inner(
init_seed: [u8; 32],
account_type: AccountType,
storage_type: AccountStorageType,
- code_root: Digest,
+ code_commitment: Digest,
storage_root: Digest,
) {
let init_seed: Vec<[u8; 8]> =
@@ -84,7 +84,7 @@ pub fn get_account_seed_inner(
Felt::new(u64::from_le_bytes(init_seed[2])),
Felt::new(u64::from_le_bytes(init_seed[3])),
];
- let mut current_digest = compute_digest(current_seed, code_root, storage_root);
+ let mut current_digest = compute_digest(current_seed, code_commitment, storage_root);
#[cfg(feature = "log")]
let mut log = log::Log::start(current_digest, current_seed, account_type, storage_type);
@@ -116,7 +116,7 @@ pub fn get_account_seed_inner(
}
}
current_seed = current_digest.into();
- current_digest = compute_digest(current_seed, code_root, storage_root);
+ current_digest = compute_digest(current_seed, code_commitment, storage_root);
}
}
@@ -125,10 +125,10 @@ pub fn get_account_seed(
init_seed: [u8; 32],
account_type: AccountType,
storage_type: AccountStorageType,
- code_root: Digest,
+ code_commitment: Digest,
storage_root: Digest,
) -> Result {
- get_account_seed_single(init_seed, account_type, storage_type, code_root, storage_root)
+ get_account_seed_single(init_seed, account_type, storage_type, code_commitment, storage_root)
}
/// Finds and returns a seed suitable for creating an account ID for the specified account type
@@ -137,7 +137,7 @@ pub fn get_account_seed_single(
init_seed: [u8; 32],
account_type: AccountType,
storage_type: AccountStorageType,
- code_root: Digest,
+ code_commitment: Digest,
storage_root: Digest,
) -> Result {
let init_seed: Vec<[u8; 8]> =
@@ -148,7 +148,7 @@ pub fn get_account_seed_single(
Felt::new(u64::from_le_bytes(init_seed[2])),
Felt::new(u64::from_le_bytes(init_seed[3])),
];
- let mut current_digest = compute_digest(current_seed, code_root, storage_root);
+ let mut current_digest = compute_digest(current_seed, code_commitment, storage_root);
#[cfg(feature = "log")]
let mut log = log::Log::start(current_digest, current_seed, account_type, storage_type);
@@ -172,7 +172,7 @@ pub fn get_account_seed_single(
}
}
current_seed = current_digest.into();
- current_digest = compute_digest(current_seed, code_root, storage_root);
+ current_digest = compute_digest(current_seed, code_commitment, storage_root);
}
}
diff --git a/objects/src/testing/account_code.rs b/objects/src/testing/account_code.rs
index 85168f2b3..a8266c555 100644
--- a/objects/src/testing/account_code.rs
+++ b/objects/src/testing/account_code.rs
@@ -101,7 +101,7 @@ impl AccountCode {
# acct proc 5
export.set_code
padw swapw
- # => [CODE_ROOT, 0, 0, 0, 0]
+ # => [CODE_COMMITMENT, 0, 0, 0, 0]
exec.account::set_code
# => [0, 0, 0, 0]