-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
20 changed files
with
296 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.