Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
wborgeaud committed Nov 3, 2023
1 parent fbd4c78 commit 4f854e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
28 changes: 14 additions & 14 deletions evm/src/cpu/kernel/asm/smt/delete.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ global smt_delete:
DUP1 %eq_const(@SMT_NODE_LEAF) %jumpi(smt_delete_leaf)
PANIC // Should never happen.

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

global smt_delete_internal:
smt_delete_internal:
// stack: node_type, node_payload_ptr, key, retdest
POP
// stack: node_payload_ptr, key, retdest
Expand All @@ -35,7 +35,7 @@ global smt_delete_internal:

// Update the internal node, possibly deleting it, or returning a leaf node.
// TODO: Could replace a lot of `is_empty` check with just ISZERO.
global internal_update:
internal_update:
// Update the child first.
// stack: deleted_child_ptr, node_payload_ptr, bit, retdest
DUP3 PUSH 1 SUB
Expand All @@ -46,10 +46,10 @@ global internal_update:
// 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)
global sibling_is_internal:
sibling_is_internal:
// stack: sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest
POP
global insert_child:
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
Expand All @@ -58,41 +58,41 @@ global insert_child:
// stack: retdest, node_ptr
JUMP

global sibling_is_hash:
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)
global sibling_is_empty:
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)
global sibling_is_empty_child_is_internal:
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)

global sibling_is_empty_child_is_hash:
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)
global sibling_is_empty_child_is_empty:
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

global sibling_is_empty_child_is_leaf:
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
Expand All @@ -108,12 +108,12 @@ global sibling_is_empty_child_is_leaf:
%stack (deleted_child_ptr, node_payload_ptr, bit, retdest) -> (retdest, deleted_child_ptr)
JUMP

global sibling_is_leaf:
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)
global sibling_is_leaf_child_is_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
Expand All @@ -128,7 +128,7 @@ global sibling_is_leaf_child_is_empty:
%stack (sibling_ptr, deleted_child_ptr, node_payload_ptr, bit, retdest) -> (retdest, sibling_ptr)
JUMP

global sibling_is_leaf_child_is_non_empty:
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
Expand Down
4 changes: 2 additions & 2 deletions evm/src/cpu/kernel/tests/smt/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn test_state_smt(smt: Smt, k: U256, account: Account) -> Result<()> {
interpreter.stack()
);

// Next, execute mpt_delete, deleting the account we just inserted.
// Next, execute smt_delete, deleting the account we just inserted.
let state_trie_ptr = interpreter.get_global_metadata_field(GlobalMetadata::StateTrieRoot);
interpreter.generation_state.registers.program_counter = smt_delete;
interpreter.push(0xDEADBEEFu32.into());
Expand All @@ -74,7 +74,7 @@ fn test_state_smt(smt: Smt, k: U256, account: Account) -> Result<()> {
let state_trie_ptr = interpreter.pop();
interpreter.set_global_metadata_field(GlobalMetadata::StateTrieRoot, state_trie_ptr);

// Now, execute mpt_hash_state_trie.
// Now, execute smt_hash_state.
interpreter.generation_state.registers.program_counter = smt_hash_state;
interpreter.push(0xDEADBEEFu32.into());
interpreter.run()?;
Expand Down
1 change: 1 addition & 0 deletions evm/src/generation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ pub fn generate_traces<F: RichField + Extendable<D>, const D: usize>(
state.traces.get_lengths()
);

// TODO: fix this
// let outputs = get_outputs(&mut state)
// .map_err(|err| anyhow!("Failed to generate post-state info: {:?}", err))?;
let outputs = Default::default();
Expand Down

0 comments on commit 4f854e6

Please sign in to comment.