Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 4f854e6
Author: wborgeaud <[email protected]>
Date:   Fri Nov 3 13:48:23 2023 +0100

    Minor

commit fbd4c78
Merge: ad580c2 c70a785
Author: wborgeaud <[email protected]>
Date:   Fri Nov 3 13:42:45 2023 +0100

    Merge branch 'feat/type2' into type2/smt_deletion

    # Conflicts:
    #	evm/src/cpu/kernel/aggregator.rs
    #	evm/src/cpu/kernel/asm/mpt/storage/storage_write.asm
    #	evm/src/cpu/kernel/asm/smt/insert.asm
    #	evm/src/cpu/kernel/asm/smt/utils.asm
    #	evm/src/cpu/kernel/constants/mod.rs
    #	evm/src/cpu/kernel/tests/smt/mod.rs
    #	evm/tests/selfdestruct.rs

commit c70a785
Author: wborgeaud <[email protected]>
Date:   Fri Nov 3 13:37:19 2023 +0100

    Start of SMT implementation for Type 2 zkEVM (#1315)

    * Add SMT types

    * Progress

    * Progress

    * Working smt hashing

    * Minor

    * Fix hash

    * Working insert

    * Minor

    * Add insert test for storage trie

    * Add missing constraints for DUP/SWAP (#1310)

    * Refactor wcopy syscalls

    * Refactor memcpy

    * Working test_simple_transfer

    * Modify add11_yml.rs

    * Refactor codecopy

    * Fix

    * Fix calldatacopy

    * Fix test on interpreter side

    * Remove new_stack_top_channel from StackBehavior (#1296)

    * Working add11_yml.rs

    * All tests compile

    * Working test_balance

    * Minor

    * Working test_extcodesize

    * All non-ignored tests pass

    * Fix test_empty_txn_list

    * Clippy

    * smt_utils point to github

    * Comments

    * Fix kexit_info in test

    * Review

    * Update Cargo.toml

    * Move empty check inside final iteration

    * Remerge context flags (#1292)

    * Remerge context flags

    * Apply comments and revert some unwanted changes

    * Merge NOT and POP flags. (#1257)

    * Merge NOT and POP flags

    * Add comments

    * Disable remaining memory channels for POP

    * Apply comments

    * Fix stack

    * More of memcpy_bytes

    * Add some documentation in EVM crate (#1295)

    Co-authored-by: Linda Guiga <[email protected]>

    * Combine PUSH0 and PC flags. (#1256)

    * PR feedback

    * Add context constraints (#1260)

    * Combine JUMPDEST and KECCAK_GENERAL flags. (#1259)

    * Combine JUMPDEST and KECCAK_GENERAL flags.

    * Apply comments

    * Fix merging of jumpdest and keccak_general.

    * Add test for selfdestruct (#1321)

    * Add test for selfdestruct

    * Comment

    * Fix test

    ---------

    Co-authored-by: Hamy Ratoanina <[email protected]>
    Co-authored-by: Robin Salen <[email protected]>
    Co-authored-by: Linda Guiga <[email protected]>
    Co-authored-by: Robin Salen <[email protected]>
    Co-authored-by: Linda Guiga <[email protected]>
    Co-authored-by: Linda Guiga <[email protected]>

commit ad580c2
Author: wborgeaud <[email protected]>
Date:   Thu Nov 2 08:40:46 2023 +0100

    Clippy

commit fe5b8fd
Author: wborgeaud <[email protected]>
Date:   Thu Nov 2 08:39:26 2023 +0100

    s/mpt/smt in a bunch of places

commit 73dc262
Author: wborgeaud <[email protected]>
Date:   Thu Nov 2 08:15:56 2023 +0100

    Selfdestruct test passes

commit 539190f
Merge: e110941 f71f227
Author: wborgeaud <[email protected]>
Date:   Thu Nov 2 07:58:15 2023 +0100

    Merge branch 'main' into type2/smt_deletion

commit e110941
Author: wborgeaud <[email protected]>
Date:   Wed Nov 1 17:04:38 2023 +0100

    Minor

commit f7fba35
Author: wborgeaud <[email protected]>
Date:   Wed Nov 1 12:24:13 2023 +0100

    PR feedback

commit e528b89
Author: wborgeaud <[email protected]>
Date:   Mon Oct 30 09:11:25 2023 +0100

    Update Cargo.toml

commit 5eaf83e
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 12:34:52 2023 +0200

    Comments

commit ae9c443
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 11:51:16 2023 +0200

    smt_utils point to github

commit b3d61b7
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 11:49:33 2023 +0200

    Clippy

commit ccb3d7e
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 10:00:20 2023 +0200

    Fix test_empty_txn_list

commit 986b010
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 09:48:14 2023 +0200

    All non-ignored tests pass

commit 7bb0c02
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 09:44:40 2023 +0200

    Working test_extcodesize

commit b8a85d4
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 09:38:08 2023 +0200

    Minor

commit 2c01b05
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 09:37:05 2023 +0200

    Working test_balance

commit e370b62
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 09:13:36 2023 +0200

    All tests compile

commit f21bc5c
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 08:31:04 2023 +0200

    Working add11_yml.rs

commit 4e2b3f3
Author: wborgeaud <[email protected]>
Date:   Thu Oct 26 18:50:32 2023 +0200

    Modify add11_yml.rs

commit c324412
Author: wborgeaud <[email protected]>
Date:   Thu Oct 26 18:28:21 2023 +0200

    Working test_simple_transfer

commit df55e45
Author: wborgeaud <[email protected]>
Date:   Thu Oct 26 08:54:24 2023 +0200

    Add insert test for storage trie

commit ca0102f
Author: wborgeaud <[email protected]>
Date:   Thu Oct 26 08:42:03 2023 +0200

    Minor

commit dc27351
Author: wborgeaud <[email protected]>
Date:   Thu Oct 26 08:40:57 2023 +0200

    Working insert

commit f6c4067
Author: wborgeaud <[email protected]>
Date:   Wed Oct 25 08:07:31 2023 +0200

    Fix hash

commit c6e85eb
Author: wborgeaud <[email protected]>
Date:   Wed Oct 18 18:46:32 2023 +0200

    Minor

commit d95c430
Author: wborgeaud <[email protected]>
Date:   Wed Oct 18 18:32:05 2023 +0200

    Working smt hashing

commit fd09915
Author: wborgeaud <[email protected]>
Date:   Wed Oct 18 14:32:38 2023 +0200

    Progress

commit a706cda
Author: wborgeaud <[email protected]>
Date:   Wed Oct 18 07:37:26 2023 +0200

    Progress

commit 95e5cc1
Author: wborgeaud <[email protected]>
Date:   Fri Oct 13 09:19:45 2023 +0200

    Add SMT types
  • Loading branch information
pgebheim committed Nov 3, 2023
1 parent 7e4de49 commit d65fe1a
Show file tree
Hide file tree
Showing 20 changed files with 296 additions and 53 deletions.
1 change: 1 addition & 0 deletions evm/src/cpu/kernel/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub(crate) fn combined_kernel() -> Kernel {
include_str!("asm/smt/hash.asm"),
include_str!("asm/smt/insert.asm"),
include_str!("asm/smt/read.asm"),
include_str!("asm/smt/delete.asm"),
include_str!("asm/smt/utils.asm"),
include_str!("asm/smt/accounts.asm"),
include_str!("asm/mpt/delete/delete.asm"),
Expand Down
2 changes: 1 addition & 1 deletion evm/src/cpu/kernel/asm/core/create.asm
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ create_too_deep:
global set_codehash:
// stack: addr, codehash, retdest
DUP1 %insert_touched_addresses
DUP1 %mpt_read_state_trie
DUP1 %smt_read_state
// stack: account_ptr, addr, codehash, retdest
%add_const(3)
// stack: codehash_ptr, addr, codehash, retdest
Expand Down
4 changes: 2 additions & 2 deletions evm/src/cpu/kernel/asm/core/create_contract_account.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%macro create_contract_account
// stack: address
DUP1 %insert_touched_addresses
DUP1 %mpt_read_state_trie
DUP1 %smt_read_state
// stack: existing_account_ptr, address
// If the account doesn't exist, there's no need to check its balance or nonce,
// so we can skip ahead, setting existing_balance = existing_account_ptr = 0.
Expand Down Expand Up @@ -46,7 +46,7 @@
// stack: address, account_ptr
%addr_to_state_key
// stack: state_key, account_ptr
%mpt_insert_state_trie
%smt_insert_state
// stack: (empty)
PUSH 0 // success
%jump(%%end)
Expand Down
2 changes: 1 addition & 1 deletion evm/src/cpu/kernel/asm/core/terminate.asm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ global sys_selfdestruct:
// stack: balance, address, recipient, kexit_info
PUSH 0
// stack: 0, balance, address, recipient, kexit_info
DUP3 %mpt_read_state_trie
DUP3 %smt_read_state
// stack: account_ptr, 0, balance, address, recipient, kexit_info
%add_const(1)
// stack: balance_ptr, 0, balance, address, recipient, kexit_info
Expand Down
2 changes: 1 addition & 1 deletion evm/src/cpu/kernel/asm/core/util.asm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// Returns 1 if the account is non-existent, 0 otherwise.
%macro is_non_existent
// stack: addr
%mpt_read_state_trie ISZERO
%smt_read_state ISZERO
%endmacro

// Returns 1 if the account is empty, 0 otherwise.
Expand Down
4 changes: 2 additions & 2 deletions evm/src/cpu/kernel/asm/journal/account_destroyed.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ revert_account_destroyed_contd:
SWAP1
// Remove `prev_balance` from `target`'s balance.
// stack: target, address, prev_balance, retdest
%mpt_read_state_trie
%smt_read_state
%add_const(1)
// stack: target_balance_ptr, address, prev_balance, retdest
DUP3
Expand All @@ -25,7 +25,7 @@ revert_account_destroyed_contd:
SUB SWAP1 %mstore_trie_data
// Set `address`'s balance to `prev_balance`.
// stack: address, prev_balance, retdest
%mpt_read_state_trie
%smt_read_state
%add_const(1)
%mstore_trie_data
JUMP
Expand Down
2 changes: 1 addition & 1 deletion evm/src/cpu/kernel/asm/journal/code_change.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ global revert_code_change:
POP
%journal_load_2
// stack: address, prev_codehash, retdest
%mpt_read_state_trie
%smt_read_state
// stack: account_ptr, prev_codehash, retdest
%add_const(3)
// stack: codehash_ptr, prev_codehash, retdest
Expand Down
2 changes: 1 addition & 1 deletion evm/src/cpu/kernel/asm/journal/nonce_change.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ global revert_nonce_change:
POP
%journal_load_2
// stack: address, prev_nonce, retdest
%mpt_read_state_trie
%smt_read_state
// stack: nonce_ptr, prev_nonce retdest
%mstore_trie_data
// stack: retdest
Expand Down
16 changes: 7 additions & 9 deletions evm/src/cpu/kernel/asm/journal/storage_change.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ global revert_storage_change:
// stack: storage_key, address, prev_value, retdest
PUSH 64 // storage_key has 64 nibbles
// stack: 64, storage_key, address, prev_value, retdest
DUP3 %mpt_read_state_trie
DUP3 %smt_read_state
DUP1 ISZERO %jumpi(panic)
// stack: account_ptr, 64, storage_key, address, prev_value, retdest
%add_const(2)
Expand All @@ -33,20 +33,18 @@ delete:
%stack (slot, address, retdest) -> (slot, new_storage_root, address, retdest)
%slot_to_storage_key
// stack: storage_key, new_storage_root, address, retdest
PUSH 64 // storage_key has 64 nibbles
// stack: 64, storage_key, new_storage_root, address, retdest
DUP4 %mpt_read_state_trie
DUP3 %smt_read_state
DUP1 ISZERO %jumpi(panic)
// stack: account_ptr, 64, storage_key, new_storage_root, address, retdest
// stack: account_ptr, storage_key, new_storage_root, address, retdest
%add_const(2)
// stack: storage_root_ptr_ptr, 64, storage_key, new_storage_root, address, retdest
// stack: storage_root_ptr_ptr, storage_key, new_storage_root, address, retdest
%mload_trie_data
// stack: storage_root_ptr, 64, storage_key, new_storage_root, address, retdest
%jump(mpt_delete)
// stack: storage_root_ptr, storage_key, new_storage_root, address, retdest
%jump(smt_delete)

new_storage_root:
// stack: new_storage_root_ptr, address, retdest
DUP2 %mpt_read_state_trie
DUP2 %smt_read_state
// stack: account_ptr, new_storage_root_ptr, address, retdest

// Update account with our new storage root pointer.
Expand Down
21 changes: 0 additions & 21 deletions evm/src/cpu/kernel/asm/mpt/delete/delete.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,3 @@ mpt_delete_leaf:
%pop4
PUSH 0 // empty node ptr
SWAP1 JUMP

global delete_account:
%stack (address, retdest) -> (address, delete_account_save, retdest)
%addr_to_state_key
// stack: key, delete_account_save, retdest
PUSH 64
// stack: 64, key, delete_account_save, retdest
%mload_global_metadata(@GLOBAL_METADATA_STATE_TRIE_ROOT)
// stack: state_root_prt, 64, key, delete_account_save, retdest
%jump(mpt_delete)
delete_account_save:
// stack: updated_state_root_ptr, retdest
%mstore_global_metadata(@GLOBAL_METADATA_STATE_TRIE_ROOT)
JUMP

%macro delete_account
%stack (address) -> (address, %%after)
%jump(delete_account)
%%after:
// stack: (empty)
%endmacro
6 changes: 2 additions & 4 deletions evm/src/cpu/kernel/asm/mpt/storage/storage_write.asm
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,12 @@ sstore_noop:

// Delete the slot from the storage SMT.
sstore_delete:
PANIC // TODO: Not implemented for SMT.
// stack: slot, value, kexit_info
SWAP1 POP
PUSH after_storage_insert SWAP1
// stack: slot, after_storage_insert, kexit_info
%slot_to_storage_key
// stack: storage_key, after_storage_insert, kexit_info
PUSH 64 // storage_key has 64 nibbles
%current_storage_smt
// stack: storage_root_ptr, 64, storage_key, after_storage_insert, kexit_info
%jump(mpt_delete)
// stack: storage_root_ptr, storage_key, after_storage_insert, kexit_info
%jump(smt_delete)
154 changes: 154 additions & 0 deletions evm/src/cpu/kernel/asm/smt/delete.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
// Return a copy of the given node with the given key deleted.
// Assumes that the key is in the SMT.
//
// Pre stack: node_ptr, key, retdest
// Post stack: updated_node_ptr
global smt_delete:
// stack: node_ptr, key, retdest
DUP1 %mload_trie_data
// stack: node_type, node_ptr, key, retdest
// Increment node_ptr, so it points to the node payload instead of its type.
SWAP1 %increment SWAP1
// stack: node_type, node_payload_ptr, key, retdest

DUP1 %eq_const(@SMT_NODE_INTERNAL) %jumpi(smt_delete_internal)
DUP1 %eq_const(@SMT_NODE_LEAF) %jumpi(smt_delete_leaf)
PANIC // Should never happen.

smt_delete_leaf:
// stack: node_type, node_payload_ptr, key, retdest
%pop3
PUSH 0 // empty node ptr
SWAP1 JUMP

smt_delete_internal:
// stack: node_type, node_payload_ptr, key, retdest
POP
// stack: node_payload_ptr, key, retdest
SWAP1 %pop_bit
%stack (bit, key, node_payload_ptr, retdest) -> (bit, node_payload_ptr, key, internal_update, node_payload_ptr, bit, retdest)
ADD
// stack: child_ptr_ptr, key, internal_update, node_payload_ptr, bit, retdest
%mload_trie_data
// stack: child_ptr, key, internal_update, node_payload_ptr, bit, retdest
%jump(smt_delete)

// Update the internal node, possibly deleting it, or returning a leaf node.
// TODO: Could replace a lot of `is_empty` check with just ISZERO.
internal_update:
// Update the child first.
// stack: deleted_child_ptr, node_payload_ptr, bit, retdest
DUP3 PUSH 1 SUB
// stack: 1-bit, deleted_child_ptr, node_payload_ptr, bit, retdest
DUP3 ADD
// stack: sibling_ptr_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
%mload_trie_data DUP1 %mload_trie_data
// stack: sibling_node_type, sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
DUP1 %eq_const(@SMT_NODE_HASH) %jumpi(sibling_is_hash)
%eq_const(@SMT_NODE_LEAF) %jumpi(sibling_is_leaf)
sibling_is_internal:
// stack: sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
POP
insert_child:
// stack: deleted_child_ptr, node_payload_ptr, bit, retdest
%stack (deleted_child_ptr, node_payload_ptr, bit) -> (node_payload_ptr, bit, deleted_child_ptr, node_payload_ptr)
ADD %mstore_trie_data
// stack: node_payload_ptr, retdest
%decrement SWAP1
// stack: retdest, node_ptr
JUMP

sibling_is_hash:
// stack: sibling_node_type, sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
POP
// stack: sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
%increment %mload_trie_data
// stack: hash, deleted_child_ptr, node_payload_ptr, bit, retdest
%jumpi(insert_child)
sibling_is_empty:
// stack: deleted_child_ptr, node_payload_ptr, bit, retdest
DUP1 %mload_trie_data
// stack: deleted_child_node_type, deleted_child_ptr, node_payload_ptr, bit, retdest
DUP1 %eq_const(@SMT_NODE_HASH) %jumpi(sibling_is_empty_child_is_hash)
DUP1 %eq_const(@SMT_NODE_LEAF) %jumpi(sibling_is_empty_child_is_leaf)
sibling_is_empty_child_is_internal:
// stack: deleted_child_node_type, deleted_child_ptr, node_payload_ptr, bit, retdest
POP
// stack: deleted_child_ptr, node_payload_ptr, bit, retdest
%jump(insert_child)

sibling_is_empty_child_is_hash:
// stack: deleted_child_node_type, deleted_child_ptr, node_payload_ptr, bit, retdest
POP
// stack: deleted_child_ptr, node_payload_ptr, bit, retdest
DUP1 %increment %mload_trie_data
// stack: hash, deleted_child_ptr, node_payload_ptr, bit, retdest
%jumpi(insert_child)
sibling_is_empty_child_is_empty:
// We can just delete this node.
// stack: deleted_child_ptr, node_payload_ptr, bit, retdest
%pop3
SWAP1 PUSH 0
// stack: retdest, 0
JUMP

sibling_is_empty_child_is_leaf:
// stack: deleted_child_node_type, deleted_child_ptr, node_payload_ptr, bit, retdest
POP
// stack: deleted_child_ptr, node_payload_ptr, bit, retdest
DUP1 %increment %mload_trie_data
// stack: child_key_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
DUP1 %mload_trie_data
// stack: key, child_key_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
%shl_const(1)
// stack: key<<1, child_key_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
DUP5 ADD
// stack: new_key, child_key_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
SWAP1 %mstore_trie_data
%stack (deleted_child_ptr, node_payload_ptr, bit, retdest) -> (retdest, deleted_child_ptr)
JUMP

sibling_is_leaf:
// stack: sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
DUP2 %is_non_empty_node
// stack: child_is_non_empty, sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
%jumpi(sibling_is_leaf_child_is_non_empty)
sibling_is_leaf_child_is_empty:
// stack: sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
DUP1 %increment %mload_trie_data
// stack: sibling_key_ptr, sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
DUP1 %mload_trie_data
// stack: sibling_key, sibling_key_ptr, sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
%shl_const(1)
// stack: sibling_key<<1, sibling_key_ptr, sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
DUP6 PUSH 1 SUB
// stack: 1-bit, sibling_key<<1, sibling_key_ptr, sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
ADD SWAP1 %mstore_trie_data
// stack: sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
%stack (sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest) -> (retdest, sibling_ptr)
JUMP

sibling_is_leaf_child_is_non_empty:
// stack: sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
POP
// stack: deleted_child_ptr, node_payload_ptr, bit, retdest
%jump(insert_child)

global delete_account:
%stack (address, retdest) -> (address, delete_account_save, retdest)
%addr_to_state_key
// stack: key, delete_account_save, retdest
%mload_global_metadata(@GLOBAL_METADATA_STATE_TRIE_ROOT)
// stack: state_root_prt, key, delete_account_save, retdest
%jump(smt_delete)
delete_account_save:
// stack: updated_state_root_ptr, retdest
%mstore_global_metadata(@GLOBAL_METADATA_STATE_TRIE_ROOT)
JUMP

%macro delete_account
%stack (address) -> (address, %%after)
%jump(delete_account)
%%after:
// stack: (empty)
%endmacro
6 changes: 6 additions & 0 deletions evm/src/cpu/kernel/asm/smt/insert.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ smt_insert_state_set_root:
// stack: retdest
JUMP

%macro smt_insert_state
%stack (key, value_ptr) -> (key, value_ptr, %%after)
%jump(smt_insert_state)
%%after:
%endmacro

// Insert a key-value pair in the SMT at `trie_data[node_ptr]`.
// `value_ptr` should point to a an empty slot reserved for `rem_key`, followed by the actual value.
// Pseudocode:
Expand Down
12 changes: 12 additions & 0 deletions evm/src/cpu/kernel/asm/smt/utils.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@
SWAP1 %and_const(1)
// stack: key&1, key>>1
%endmacro

// Returns a non-zero value if the node is non-empty.
%macro is_non_empty_node
// stack: node_ptr
DUP1 %mload_trie_data %jumpi(%%end) // If the node is not a hash node, node_ptr is non-zero.
// The node is a hash node
// stack: node_ptr
%increment %mload_trie_data
// stack: hash
%jump(%%end)
%%end:
%endmacro
11 changes: 5 additions & 6 deletions evm/src/cpu/kernel/asm/transactions/common_decoding.asm
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,16 @@ sload_with_addr:
%stack (slot, addr) -> (slot, addr, after_storage_read)
%slot_to_storage_key
// stack: storage_key, addr, after_storage_read
PUSH 64 // storage_key has 64 nibbles
%stack (n64, storage_key, addr, after_storage_read) -> (addr, n64, storage_key, after_storage_read)
%mpt_read_state_trie
// stack: account_ptr, 64, storage_key, after_storage_read
%stack (storage_key, addr, after_storage_read) -> (addr, storage_key, after_storage_read)
%smt_read_state
// stack: account_ptr, storage_key, after_storage_read
DUP1 ISZERO %jumpi(ret_zero) // TODO: Fix this. This should never happen.
// stack: account_ptr, 64, storage_key, after_storage_read
// stack: account_ptr, storage_key, after_storage_read
%add_const(2)
// stack: storage_root_ptr_ptr
%mload_trie_data
// stack: storage_root_ptr, 64, storage_key, after_storage_read
%jump(mpt_read)
%jump(smt_read)

ret_zero:
// stack: account_ptr, 64, storage_key, after_storage_read, retdest
Expand Down
Loading

0 comments on commit d65fe1a

Please sign in to comment.