Skip to content

Commit

Permalink
refactor: update padding before calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Fumuran committed Aug 9, 2024
1 parent a8a3aab commit 9e3849c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion miden-lib/asm/kernels/transaction/api.masm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use.miden::kernels::tx::tx

# NOTE
# =================================================================================================
# Procedures in this module are expected to be invoked using a `call` instruction. It makes no #
# 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. #
# =================================================================================================
Expand Down
8 changes: 4 additions & 4 deletions miden-lib/asm/miden/tx.masm
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ end
export.create_note
# pad the stack before the syscall to prevent accidental modification of the deeper stack
# elements
push.0 movdn.7 padw padw movdnw.3 movdnw.3
push.0 movdn.7 padw padw swapdw
# => [tag, aux, note_type, RECIPIENT, PAD(9)]

syscall.create_note
# => [note_idx, PAD(15)]

# remove excess PADs from the stack
movdnw.3 dropw dropw dropw movdn.3 drop drop drop
swapdw dropw dropw movdn.7 dropw drop drop drop
# => [note_idx]
end

Expand All @@ -87,14 +87,14 @@ end
export.add_asset_to_note
# pad the stack before the syscall to prevent accidental modification of the deeper stack
# elements
push.0.0.0 padw padw movupw.3 movup.15 movup.4
push.0.0.0 padw padw swapdw movup.7 swapw movup.4
# => [note_idx, ASSET, PAD(11)]

syscall.add_asset_to_note
# => [note_idx, ASSET, PAD(11)]

# remove excess PADs from the stack
movdn.15 movdnw.3 dropw dropw drop drop drop movdn.4
swapdw dropw dropw swapw movdn.7 drop drop drop movdn.4
# => [ASSET, note_idx]
end

Expand Down
10 changes: 5 additions & 5 deletions miden-tx/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ fn test_send_note_proc() {
# => [tag, aux, note_type, RECIPIENT, ...]
# pad the stack with zeros before calling the `cteate_note`.
push.0 movdn.7 padw padw movdnw.3 movdnw.3
push.0 movdn.7 padw padw swapdw
# => [tag, aux, note_type, RECIPIENT, PAD(9) ...]
call.wallet::cteate_note
Expand Down Expand Up @@ -685,28 +685,28 @@ fn executed_transaction_output_notes() {
proc.create_note
# pad the stack before the call to prevent accidental modification of the deeper stack
# elements
push.0 movdn.7 padw padw movdnw.3 movdnw.3
push.0 movdn.7 padw padw swapdw
# => [tag, aux, note_type, RECIPIENT, PAD(9)]
call.{ACCOUNT_CREATE_NOTE_MAST_ROOT}
# => [note_idx, PAD(15)]
# remove excess PADs from the stack
movdnw.3 dropw dropw dropw movdn.3 drop drop drop
swapdw dropw dropw movdn.7 dropw drop drop drop
# => [note_idx]
end
proc.add_asset_to_note
# pad the stack before the syscall to prevent accidental modification of the deeper stack
# elements
push.0.0.0 padw padw movupw.3 movup.15
push.0.0.0 padw padw swapdw movup.7 swapw
# => [ASSET, note_idx, PAD(11)]
call.{ACCOUNT_ADD_ASSET_TO_NOTE_MAST_ROOT}
# => [ASSET, note_idx, PAD(11)]
# remove excess PADs from the stack
movdn.15 movdnw.3 dropw dropw drop drop drop
swapdw dropw dropw swapw movdn.7 drop drop drop
# => [ASSET, note_idx]
dropw
Expand Down
10 changes: 5 additions & 5 deletions objects/src/testing/account_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ use crate::accounts::AccountCode;
// The MAST root of the default account's interface. Use these constants to interact with the
// account's procedures.
const MASTS: [&str; 13] = [
"0x8afef26974e7fdb12d7e2af49e92f68b09c504e5c530c1283711653f242fd350",
"0x9a51f741356a6c27dd116c590ca116463ff41d46fddc890c0aa6c2dc0a5c86a9",
"0xfdbbfe639d69012b47e946fd23a975d064ec19bc0f7bd45b5f65b47b059e7b01",
"0x996a35ee99d675fec9dbbe8156f53357b1d42b3105ab4dc24172d779d818c1c8",
"0xe3c24a1109379344874ac5dec91a6311e5563d0194ded29b44ed71535e78b34a",
"0x10271f1549303e22f9562bfdb73da948407a276ea0ec470deb7ce6793c316562",
"0x8ae4511f7e9841364e1a62b6594ef02e25d4404b50e18921eaaa36c765382572",
"0x28c514e509fc044a2ea6cddbab0abf2b5fa589d5c91978ae9c935ab40e6ec402",
"0xa61cdf8c75943d293ffcfca73ea07a6639dad1820d64586a2a292bb9f80a4296",
"0x6877f03ef52e490f7c9e41b297fb79bb78075ff28c6e018aaa1ee30f73e7ea4b",
"0x24e0a1587d4d1ddff74313518f5187f6042ffbe8f2ddc97d367a5c3da4b17d82",
"0x8afef26974e7fdb12d7e2af49e92f68b09c504e5c530c1283711653f242fd350",
"0x1e7fdec663be004a894d024a9354e5721f0c1b439ecce73a40e1689cf5379511",
"0xfdbbfe639d69012b47e946fd23a975d064ec19bc0f7bd45b5f65b47b059e7b01",
"0x8f66a752fed49ee97ef9281ec7e3d5d1ffad7b229aac7a96f91f5e50fd391607",
"0xcd34115714cdcda24f1d6968cbfb67b8b51c1751a2e25e9d6b4e18c35323e5ba",
"0xff06b90f849c4b262cbfbea67042c4ea017ea0e9c558848a951d44b23370bec5",
"0x8ef0092134469a1330e3c468f57c7f085ce611645d09cc7516c786fefc71d794",
Expand Down

0 comments on commit 9e3849c

Please sign in to comment.