Skip to content

Commit

Permalink
refactor: rework memory layout to create an accout data section
Browse files Browse the repository at this point in the history
  • Loading branch information
Fumuran committed Sep 17, 2024
1 parent c1fe049 commit 9b59f13
Show file tree
Hide file tree
Showing 12 changed files with 331 additions and 345 deletions.
12 changes: 6 additions & 6 deletions miden-lib/asm/kernels/transaction/lib/account.masm
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ end
#! - ACCT_HASH is the hash of the account data.
export.get_current_hash
# prepare the stack for computing the account hash
exec.memory::get_acct_data_ptr padw padw padw
exec.memory::get_current_account_data_offset padw padw padw

# stream account data and compute sequential hash. We perform two `mem_stream` operations
# because account data consists of exactly 4 words.
Expand Down Expand Up @@ -414,7 +414,7 @@ end
#! - VALUE is the value of the item.
export.get_item
# get account storage slots section offset
exec.memory::get_acct_storage_slots_section_offset
exec.memory::get_acct_storage_slots_section_ptr
# => [acct_storage_slots_section_offset, index]

# get the item from storage
Expand Down Expand Up @@ -544,7 +544,7 @@ export.get_storage_slot_type
# => [index, V']

# get account storage slots section offset
exec.memory::get_acct_storage_slots_section_offset
exec.memory::get_acct_storage_slots_section_ptr
# => [acct_storage_slots_section_offset, index]

# get storage slot type
Expand All @@ -568,7 +568,7 @@ export.get_procedure_info
# => [index]

# get procedure pointer
mul.2 exec.memory::get_acct_procedures_section_offset add dup add.1
mul.2 exec.memory::get_acct_procedures_section_ptr add dup add.1
# => [offset_ptr, proc_ptr]

# load procedure information from memory
Expand Down Expand Up @@ -702,7 +702,7 @@ proc.set_item_raw
# => [index, NEW_VALUE, OLD_VALUE]

# get account storage slots section offset
exec.memory::get_acct_storage_slots_section_offset
exec.memory::get_acct_storage_slots_section_ptr
# => [acct_storage_slots_section_offset, index, NEW_VALUE, OLD_VALUE]

# update storage
Expand All @@ -725,7 +725,7 @@ end
#! - storage_offset is the procedure storage offset.
proc.get_procedure_storage_offset
# get procedure storage offset pointer
mul.2 exec.memory::get_acct_procedures_section_offset add add.1
mul.2 exec.memory::get_acct_procedures_section_ptr add add.1
# => [storage_offset_ptr]

# load procedure storage offset from memory
Expand Down
4 changes: 2 additions & 2 deletions miden-lib/asm/kernels/transaction/lib/epilogue.masm
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ proc.update_account_storage_commitment
# only loop and hash over storage if there are storage slots
if.true
# setup start and end ptr
mul.2 exec.memory::get_acct_storage_slots_section_offset dup movdn.2 add swap
mul.2 exec.memory::get_acct_storage_slots_section_ptr dup movdn.2 add swap
# => [start_ptr, end_ptr]

# pad stack to read and hash from memory
Expand Down Expand Up @@ -246,7 +246,7 @@ export.finalize_transaction
# => [acct_data_end_ptr, INIT_ACCT_HASH]

# get the offset for the start of the account data section
exec.memory::get_acct_data_ptr
exec.memory::get_current_account_data_offset
# => [acct_data_ptr, acct_data_end_ptr, INIT_ACCT_HASH]

# compute the final account hash
Expand Down
Loading

0 comments on commit 9b59f13

Please sign in to comment.