Skip to content

Commit

Permalink
after first feedback on the MASM files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik1999 committed May 2, 2024
1 parent 711ff2a commit 990fa5f
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 36 deletions.
8 changes: 4 additions & 4 deletions miden-lib/asm/kernels/transaction/api.masm
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ export.create_note
# => [ptr]

# prepare the stack for return
#padw push.0 push.0 movup.6
movupw.3 movup.15 movup.15 movup.6
# => [ptr, 0, 0, 0, 0, 0, 0]
end

Expand All @@ -542,16 +542,16 @@ end
#!
#! ptr is the pointer to the memory address at which the note is stored.
#! ASSET can be a fungible or non-fungible asset.
export.add_asset_to_note
export.move_asset_to_note
# authenticate that the procedure invocation originates from the account context
exec.authenticate_account_origin
# => [ptr, ASSET]

exec.tx::add_asset_to_note
exec.tx::move_asset_to_note
# => [ptr]

# prepare stack for return
#padw movup.4
movupw.3 movup.4
# => [ptr, 0, 0, 0, 0]
end

Expand Down
6 changes: 3 additions & 3 deletions miden-lib/asm/miden/contracts/faucets/basic_fungible.masm
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ export.distribute.1

# get total issuance of this faucet so far and add amount to be minted
exec.faucet::get_total_issuance
# => [total_issuance, max_supply, amount, tag, note_type RECIPIENT, ...]
# => [total_issuance, max_supply, amount, tag, aux, note_type RECIPIENT, ...]

# compute maximum amount that can be minted, max_mint_amount = max_supply - total_issuance
sub
# => [max_supply - total_issuance, amount, tag, note_type, RECIPIENT, ...]
# => [max_supply - total_issuance, amount, tag, aux, note_type, RECIPIENT, ...]

# check that amount =< max_supply - total_issuance, fails if otherwise
dup.1 gte assert.err=ERR_BASIC_FUNGIBLE_MAX_SUPPLY_OVERFLOW
Expand All @@ -86,7 +86,7 @@ export.distribute.1
# => [note_ptr, ASSET, ZERO, ...]

# add the ASSET to the note
exec.tx::add_asset_to_note
exec.tx::move_asset_to_note
# => [note_ptr, ZERO, ...]
end

Expand Down
2 changes: 1 addition & 1 deletion miden-lib/asm/miden/contracts/wallets/basic.masm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export.send_asset.1
padw loc_loadw.0 movup.4
# => [note_ptr, ASSET, 0, 0, 0, ZERO, ZERO, ...]

exec.tx::add_asset_to_note
exec.tx::move_asset_to_note
# => [note_ptr, ZERO, 0, ...]

# organize the stack for return
Expand Down
6 changes: 3 additions & 3 deletions miden-lib/asm/miden/kernels/tx/asset.masm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const.ERR_NON_FUNGIBLE_ASSET_MISMATCH=0x0002003A

const.FUNGIBLE_ASSET_MAX_AMOUNT=9223372036854775807

# This mask defines the bit in the most significant half of the element which
# This mask defines the bit in the most significant half of the element which
# is used to identify the asset type
const.FUNGIBLE_BITMASK_U32=0x20000000

Expand Down Expand Up @@ -104,11 +104,11 @@ export.validate_non_fungible_asset
dup.2 exec.account::validate_id
# => [ASSET]

# assert that ASSET[1] is a fungible faucet
# assert that ASSET[1] is a non-fungible faucet
dup.2 exec.account::is_non_fungible_faucet assert.err=ERR_NON_FUNGIBLE_ASSET_FORMAT_POSITION_ONE_MUST_FUNGIBLE
# => [ASSET]

# assert the fungible bit is set to 0
# assert the non-fungible high bit is set to 0
dup u32split push.FUNGIBLE_BITMASK_U32 u32and assertz.err=ERR_NON_FUNGIBLE_ASSET_HIGH_BIT_SET drop
# => [ASSET]
end
Expand Down
2 changes: 1 addition & 1 deletion miden-lib/asm/miden/kernels/tx/asset_vault.masm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ end
# ADD ASSET
# =================================================================================================

#! Add the specified fungible asset to the vault. If the vault already contains an asset
#! Add the specified fungible asset to the vault. If the vault already contains an asset
#! issued by the same faucet, the amounts are added together.
#!
#! Panics:
Expand Down
2 changes: 1 addition & 1 deletion miden-lib/asm/miden/kernels/tx/tx.masm
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ end
#!
#! ptr is the pointer to the memory address at which the note is stored.
#! ASSET can be a fungible or non-fungible asset.
export.add_asset_to_note
export.move_asset_to_note
# validate the ASSET
movdn.4 exec.asset::validate_asset
# => [ASSET, ptr]
Expand Down
4 changes: 2 additions & 2 deletions miden-lib/asm/miden/tx.masm
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ end
#!
#! ptr is the pointer to the memory address at which the note is stored.
#! ASSET can be a fungible or non-fungible asset.
export.add_asset_to_note
syscall.add_asset_to_note
export.move_asset_to_note
syscall.move_asset_to_note
# => [ptr, ZERO]

# clear the padding from the kernel response
Expand Down
12 changes: 6 additions & 6 deletions miden-lib/src/tests/test_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fn test_create_note_with_one_asset() {
# => [note_ptr]
push.{asset} movup.4
exec.tx::add_asset_to_note
exec.tx::move_asset_to_note
end
",
recipient = prepare_word(&recipient),
Expand Down Expand Up @@ -293,10 +293,10 @@ fn test_create_note_with_two_different_fungible_assets() {
# => [note_ptr]
push.{asset_1} movup.4
exec.tx::add_asset_to_note
exec.tx::move_asset_to_note
push.{asset_2} movup.4
exec.tx::add_asset_to_note
exec.tx::move_asset_to_note
end
",
recipient = prepare_word(&recipient),
Expand Down Expand Up @@ -385,10 +385,10 @@ fn test_create_note_with_two_fungible_assets_of_same_type() {
# => [note_ptr]
push.{asset_1} movup.4
exec.tx::add_asset_to_note
exec.tx::move_asset_to_note
push.{asset_2} movup.4
exec.tx::add_asset_to_note
exec.tx::move_asset_to_note
end
",
recipient = prepare_word(&recipient),
Expand Down Expand Up @@ -569,7 +569,7 @@ fn test_get_output_notes_hash() {
# => [note_ptr]
push.{asset_1} movup.4
exec.tx::add_asset_to_note
exec.tx::move_asset_to_note
# => [note_ptr]
drop
Expand Down
2 changes: 1 addition & 1 deletion miden-tx/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn executed_transaction_account_delta() {
# => [ptr]
end
proc.add_asset_to_note
proc.move_asset_to_note
call.{ACCOUNT_ADD_ASSET_TO_NOTE_MAST_ROOT}
drop
Expand Down
17 changes: 3 additions & 14 deletions mock/src/mock/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,7 @@ pub fn mock_account_storage() -> AccountStorage {

// The MAST root of the default account's interface. Use these constants to interact with the
// account's procedures.
const MASTS: [&str; 10] = [
"0xe06a83054c72efc7e32698c4fc6037620cde834c9841afb038a5d39889e502b6",
"0xa6462d2b515d70d9c70d2a06e3ad78aafa1970b644597a13baef836d5e8bd9a0",
"0xd765111e22479256e87a57eaf3a27479d19cc876c9a715ee6c262e0a0d47a2ac",
"0x17b326d5403115afccc0727efa72bd929bfdc7bbf284c7c28a7aadade5d4cc9d",
"0x6682a0e0f4e49820e5c547f1b60a82cb326a56c972999e36bf6d45459393ac87",
"0x73c14f65d2bab6f52eafc4397e104b3ab22a470f6b5cbc86d4aa4d3978c8b7d4",
"0x6c400847f3f0d01a76c568cf4c3e7bc85c0038c564fb169902f0cab6c105401c",
"0xec1353da46e05795e5dd7fe2e54b56a7c6b9323394385090e6da9374f5fbf6ed",
"0xff06b90f849c4b262cbfbea67042c4ea017ea0e9c558848a951d44b23370bec5",
"0x8ef0092134469a1330e3c468f57c7f085ce611645d09cc7516c786fefc71d794",
];
const MASTS: [&str; 10] = ["0xe06a83054c72efc7e32698c4fc6037620cde834c9841afb038a5d39889e502b6", "0x54d491aa6d87352cfcbe4656cde8e49e50936080625133fe763a5f6206d1fd84", "0xd765111e22479256e87a57eaf3a27479d19cc876c9a715ee6c262e0a0d47a2ac", "0x17b326d5403115afccc0727efa72bd929bfdc7bbf284c7c28a7aadade5d4cc9d", "0x6682a0e0f4e49820e5c547f1b60a82cb326a56c972999e36bf6d45459393ac87", "0x73c14f65d2bab6f52eafc4397e104b3ab22a470f6b5cbc86d4aa4d3978c8b7d4", "0x66bff9f74df3a91736cb1bbd5a29c52755514734cd6d6ef161601b776464dfc7", "0xc97999935cb40f06c13b4be7a799479eb4ab3d50884b36d461f8b2d36fc29a5f", "0xff06b90f849c4b262cbfbea67042c4ea017ea0e9c558848a951d44b23370bec5", "0x8ef0092134469a1330e3c468f57c7f085ce611645d09cc7516c786fefc71d794"];
pub const ACCOUNT_RECEIVE_ASSET_MAST_ROOT: &str = MASTS[0];
pub const ACCOUNT_SEND_ASSET_MAST_ROOT: &str = MASTS[1];
pub const ACCOUNT_INCR_NONCE_MAST_ROOT: &str = MASTS[2];
Expand Down Expand Up @@ -207,8 +196,8 @@ pub fn mock_account_code(assembler: &Assembler) -> AccountCode {
end
# acct proc 7
export.add_asset_to_note
exec.tx::add_asset_to_note
export.move_asset_to_note
exec.tx::move_asset_to_note
# => [ptr, 0, 0, 0, 0, 0, 0, 0, 0, 0]
end
Expand Down

0 comments on commit 990fa5f

Please sign in to comment.