Skip to content

Commit 093ac8e

Browse files
committed
style: use the '# =>' stack-comment convention in the batch kernel masm
Match the operand-stack (# =>) and advice-stack (# AS =>) comment style used throughout the rest of the protocol assembly.
1 parent be707bc commit 093ac8e

3 files changed

Lines changed: 38 additions & 38 deletions

File tree

crates/miden-protocol/asm/kernels/batch/lib/note_tracker.masm

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,39 @@ proc absorb_scratch_into_batch_hasher
2222
push.0 exec.memory::set_scratch_word_index
2323

2424
exec.memory::load_batch_hasher_state
25-
# Stack: [RATE0, RATE1, CAPACITY]
25+
# => [RATE0, RATE1, CAPACITY]
2626

2727
exec.memory::get_scratch_word_index
2828
exec.memory::get_scratch_words_count
2929
u32lt
30-
# Stack: [should_loop, RATE0, RATE1, CAPACITY]
30+
# => [should_loop, RATE0, RATE1, CAPACITY]
3131

3232
while.true
3333
exec.memory::get_scratch_word_index
3434
mul.4 add.TX_NOTES_SCRATCH_PTR
35-
# Stack: [scratch_ptr, RATE0, RATE1, CAPACITY]
35+
# => [scratch_ptr, RATE0, RATE1, CAPACITY]
3636

3737
padw dup.4 mem_loadw_le
38-
# Stack: [DATA1, scratch_ptr, RATE0, RATE1, CAPACITY]
38+
# => [DATA1, scratch_ptr, RATE0, RATE1, CAPACITY]
3939

4040
padw dup.8 add.4 mem_loadw_le
41-
# Stack: [DATA2, DATA1, scratch_ptr, RATE0, RATE1, CAPACITY]
41+
# => [DATA2, DATA1, scratch_ptr, RATE0, RATE1, CAPACITY]
4242

4343
movup.8 drop
44-
# Stack: [DATA2, DATA1, RATE0, RATE1, CAPACITY]
44+
# => [DATA2, DATA1, RATE0, RATE1, CAPACITY]
4545

4646
# Replace RATE0 + RATE1 with DATA1 + DATA2 (DATA1 first, DATA2 second), then permute.
4747
swapdw
4848
dropw dropw
4949
swapw
5050
exec.poseidon2::permute
51-
# Stack: [RATE0', RATE1', CAPACITY']
51+
# => [RATE0', RATE1', CAPACITY']
5252

5353
exec.memory::get_scratch_word_index add.2 exec.memory::set_scratch_word_index
5454
exec.memory::get_scratch_word_index
5555
exec.memory::get_scratch_words_count
5656
u32lt
57-
# Stack: [should_loop, RATE0, RATE1, CAPACITY]
57+
# => [should_loop, RATE0, RATE1, CAPACITY]
5858
end
5959

6060
exec.memory::save_batch_hasher_state
@@ -87,51 +87,51 @@ pub proc compute_input_notes_commitment
8787

8888
exec.memory::get_num_transactions
8989
push.0
90-
# Stack: [tx_index, num_transactions]
90+
# => [tx_index, num_transactions]
9191

9292
dup.1 dup.1 neq
93-
# Stack: [should_loop, tx_index, num_transactions]
93+
# => [should_loop, tx_index, num_transactions]
9494

9595
while.true
9696
dup exec.memory::get_tx_input_notes_commitment
97-
# Stack: [INPUT_NOTES_COMMITMENT_i, tx_index, num_transactions]
97+
# => [INPUT_NOTES_COMMITMENT_i, tx_index, num_transactions]
9898

9999
dupw exec.word::eqz
100-
# Stack: [is_empty, INPUT_NOTES_COMMITMENT_i, tx_index, num_transactions]
100+
# => [is_empty, INPUT_NOTES_COMMITMENT_i, tx_index, num_transactions]
101101

102102
if.true
103103
dropw
104104
else
105105
push.TX_NOTES_SCRATCH_PTR movdn.4
106-
# Stack: [INPUT_NOTES_COMMITMENT_i, tx_notes_scratch_ptr, tx_index, num_transactions]
106+
# => [INPUT_NOTES_COMMITMENT_i, tx_notes_scratch_ptr, tx_index, num_transactions]
107107

108108
adv.push_mapvaln
109109
adv_push div.4
110-
# Stack: [num_words, INPUT_NOTES_COMMITMENT_i, tx_notes_scratch_ptr, tx_index, num_transactions]
110+
# => [num_words, INPUT_NOTES_COMMITMENT_i, tx_notes_scratch_ptr, tx_index, num_transactions]
111111

112112
dup exec.memory::set_scratch_words_count
113113

114114
movup.5 swap
115-
# Stack: [num_words, tx_notes_scratch_ptr, INPUT_NOTES_COMMITMENT_i, tx_index, num_transactions]
115+
# => [num_words, tx_notes_scratch_ptr, INPUT_NOTES_COMMITMENT_i, tx_index, num_transactions]
116116

117117
# Pipe the note data into scratch, asserting its poseidon2 hash equals
118118
# INPUT_NOTES_COMMITMENT_i.
119119
exec.mem::pipe_preimage_to_memory
120-
# Stack: [end_ptr, tx_index, num_transactions]
120+
# => [end_ptr, tx_index, num_transactions]
121121
drop
122122

123123
exec.absorb_scratch_into_batch_hasher
124124
end
125-
# Stack: [tx_index, num_transactions]
125+
# => [tx_index, num_transactions]
126126

127127
add.1
128128
dup.1 dup.1 neq
129-
# Stack: [should_loop, tx_index, num_transactions]
129+
# => [should_loop, tx_index, num_transactions]
130130
end
131131

132132
drop drop
133133

134134
exec.memory::load_batch_hasher_state
135135
exec.poseidon2::squeeze_digest
136-
# Stack: [INPUT_NOTES_COMMITMENT]
136+
# => [INPUT_NOTES_COMMITMENT]
137137
end

crates/miden-protocol/asm/kernels/batch/lib/prologue.masm

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,59 +44,59 @@ pub proc prepare_batch
4444
# Layer 1: pipe BATCH_ID's mapped value to tx_tuples_ptr + verify.
4545
# ---------------------------------------------------------------------------------------------
4646

47-
# Stack: [BATCH_ID]
47+
# => [BATCH_ID]
4848
push.TX_TUPLES_PTR movdn.4
49-
# Stack: [BATCH_ID, tx_tuples_ptr]
49+
# => [BATCH_ID, tx_tuples_ptr]
5050

5151
adv.push_mapvaln
52-
# AS: [len_felts, data...]
52+
# AS => [len_felts, data...]
5353

5454
adv_push div.4
55-
# Stack: [num_words, BATCH_ID, tx_tuples_ptr]
55+
# => [num_words, BATCH_ID, tx_tuples_ptr]
5656

5757
# num_transactions = num_words / 2 (each tx contributes 2 words: tx_id + account_id_pair).
5858
dup div.2 exec.memory::set_num_transactions
5959

6060
movup.5 swap
61-
# Stack: [num_words, tx_tuples_ptr, BATCH_ID]
61+
# => [num_words, tx_tuples_ptr, BATCH_ID]
6262

6363
# Pipe the tuples into memory, asserting their poseidon2 hash equals BATCH_ID.
6464
exec.mem::pipe_preimage_to_memory
65-
# Stack: [end_ptr]
65+
# => [end_ptr]
6666
drop
6767

6868
# Layer 2: for each transaction, pipe + verify its header.
6969
# ---------------------------------------------------------------------------------------------
7070

7171
exec.memory::get_num_transactions
7272
push.0
73-
# Stack: [tx_index, num_transactions]
73+
# => [tx_index, num_transactions]
7474

7575
dup.1 dup.1 neq
76-
# Stack: [should_loop, tx_index, num_transactions]
76+
# => [should_loop, tx_index, num_transactions]
7777

7878
while.true
7979
dup exec.memory::get_tx_id
80-
# Stack: [TX_ID, tx_index, num_transactions]
80+
# => [TX_ID, tx_index, num_transactions]
8181

8282
dup.4 exec.memory::tx_header_ptr movdn.4
83-
# Stack: [TX_ID, tx_header_ptr, tx_index, num_transactions]
83+
# => [TX_ID, tx_header_ptr, tx_index, num_transactions]
8484

8585
adv.push_mapvaln
8686
adv_push div.4
87-
# Stack: [num_words, TX_ID, tx_header_ptr, tx_index, num_transactions]
87+
# => [num_words, TX_ID, tx_header_ptr, tx_index, num_transactions]
8888

8989
movup.5 swap
90-
# Stack: [num_words, tx_header_ptr, TX_ID, tx_index, num_transactions]
90+
# => [num_words, tx_header_ptr, TX_ID, tx_index, num_transactions]
9191

9292
# Pipe the header into memory, asserting its poseidon2 hash equals TX_ID.
9393
exec.mem::pipe_preimage_to_memory
94-
# Stack: [end_ptr, tx_index, num_transactions]
94+
# => [end_ptr, tx_index, num_transactions]
9595
drop
9696

9797
add.1
9898
dup.1 dup.1 neq
99-
# Stack: [should_loop, tx_index, num_transactions]
99+
# => [should_loop, tx_index, num_transactions]
100100
end
101101

102102
drop drop

crates/miden-protocol/asm/kernels/batch/main.masm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,24 @@ use miden::batch_kernel::prologue
5252
#! TODO: aggregate per-account updates and emit a separate ACCOUNT_UPDATES_COMMITMENT output.
5353
#! TODO: recursively verify each transaction's `ExecutionProof`.
5454
proc main
55-
# Stack: [BLOCK_COMMITMENT, BATCH_ID, pad(8)]
55+
# => [BLOCK_COMMITMENT, BATCH_ID, pad(8)]
5656

5757
# TODO: verify BLOCK_COMMITMENT against block header data via the pipe-and-verify pattern.
5858
dropw
59-
# Stack: [BATCH_ID, pad(12)]
59+
# => [BATCH_ID, pad(12)]
6060

6161
exec.prologue::prepare_batch
62-
# Stack: [pad(16)]
62+
# => [pad(16)]
6363

6464
exec.note_tracker::compute_input_notes_commitment
65-
# Stack: [INPUT_NOTES_COMMITMENT, pad(16)]
65+
# => [INPUT_NOTES_COMMITMENT, pad(16)]
6666

6767
# Drop the surplus padding word so the stack holds exactly the 16-felt output region
6868
# [INPUT_NOTES_COMMITMENT, BATCH_NOTE_TREE_ROOT, batch_expiration_block_num, pad(7)]. The
6969
# BATCH_NOTE_TREE_ROOT and batch_expiration_block_num cells stay zero (wired up in follow-up
7070
# PRs).
7171
movupw.3 dropw
72-
# Stack: [INPUT_NOTES_COMMITMENT, pad(12)]
72+
# => [INPUT_NOTES_COMMITMENT, pad(12)]
7373
end
7474

7575
begin

0 commit comments

Comments
 (0)