Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FPI: rework memory layout #882

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 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_ptr 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 @@ -186,7 +186,7 @@ end
#! Output: [acct_id]
#!
#! - acct_id is the account id.
export.memory::get_acct_id->get_id
export.memory::get_account_id->get_id

#! Returns the account nonce.
#!
Expand Down Expand Up @@ -295,7 +295,7 @@ end
#! - CODE_COMMITMENT is the hash of the code to set.
export.set_code
# get the account id
exec.memory::get_acct_id
exec.memory::get_account_id
# => [acct_id, CODE_COMMITMENT]

# assert the account is an updatable regular account
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 @@ -613,7 +613,7 @@ end
#! Output: []
export.validate_seed
# pad capacity elements of hasher and populate first four elements of the rate with the account id seed
padw exec.memory::get_acct_id push.0.0.0
padw exec.memory::get_account_id push.0.0.0
adv.push_mapval push.15263 drop # TODO: remove line, see miden-vm/#1122
adv_loadw
# => [SEED, 0, 0, 0, 0]
Expand All @@ -640,14 +640,14 @@ export.validate_seed

# assert the account id matches the account id of the new account and extract pow
# element
movdn.3 drop drop exec.memory::get_acct_id eq assert.err=ERR_ACCOUNT_SEED_DIGEST_MISMATCH
movdn.3 drop drop exec.memory::get_account_id eq assert.err=ERR_ACCOUNT_SEED_DIGEST_MISMATCH
# => [pow]

# get acct and faucet modulus to check the min number of trailing zeros required in the pow
exec.constants::get_regular_account_seed_digest_modulus exec.constants::get_faucet_seed_digest_modulus
# => [faucet_modulus, acct_modulus, pow]

exec.memory::get_acct_id
exec.memory::get_account_id
# => [acct_id, faucet_modulus, acct_modulus, pow]

exec.is_faucet
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_ptr
# => [acct_data_ptr, acct_data_end_ptr, INIT_ACCT_HASH]

# compute the final account hash
Expand Down
Loading
Loading