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 a9938cd commit de36edb
Show file tree
Hide file tree
Showing 11 changed files with 363 additions and 343 deletions.
10 changes: 5 additions & 5 deletions miden-lib/asm/kernels/transaction/lib/account.masm
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,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 @@ -353,7 +353,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 All @@ -379,7 +379,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 Down Expand Up @@ -513,7 +513,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 @@ -537,7 +537,7 @@ export.get_procedure_info
# => [index]

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

# load procedure information 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 de36edb

Please sign in to comment.