Skip to content

Commit

Permalink
Fix revert account destroyed with nonexistent target
Browse files Browse the repository at this point in the history
  • Loading branch information
LindaGuiga committed Oct 9, 2023
1 parent 0de6f94 commit fbf11c0
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions evm/src/cpu/kernel/asm/journal/account_destroyed.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,26 @@ revert_account_destroyed_contd:
// Remove `prev_balance` from `target`'s balance.
// stack: target, address, prev_balance, retdest
%mpt_read_state_trie
%add_const(1)
// Only remove `prev_balance` if `target` exists.
// stack: target_balance_ptr, address, prev_balance, retdest
DUP3
DUP2 %mload_trie_data
// stack: target_balance, prev_balance, target_balance_ptr, address, prev_balance, retdest
SUB SWAP1 %mstore_trie_data
DUP1 ISZERO ISZERO %jumpi(remove_target_balance)
recreate_account:
// Undo the account destruction.
// stack: target_balance_ptr, address, prev_balance, retdest
POP
// Set `address`'s balance to `prev_balance`.
// stack: address, prev_balance, retdest
%mpt_read_state_trie
%add_const(1)
%mstore_trie_data
JUMP

remove_target_balance:
%add_const(1)
// stack: target_balance_ptr, address, prev_balance, retdest
DUP3
DUP2 %mload_trie_data
// stack: target_balance, prev_balance, target_balance_ptr, address, prev_balance, retdest
SUB DUP2 %mstore_trie_data
// stack: target_balance_ptr, address, prev_balance, retdest
%jump(recreate_account)

0 comments on commit fbf11c0

Please sign in to comment.