Skip to content

Commit

Permalink
fix: do not add selfdestruct journal entry for empty accounts (0xPoly…
Browse files Browse the repository at this point in the history
…gonZero#328)

* fix: Do not add journal entry for skipped accounts

* Tweak to check with is_non_existent

* Reduce overhead
  • Loading branch information
Nashtare authored Jun 26, 2024
1 parent 7a01826 commit 4e80f84
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions evm_arithmetization/src/cpu/kernel/asm/core/terminate.asm
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,36 @@ global sys_selfdestruct:
%add_eth

sys_selfdestruct_journal_add:
// stack: address, recipient, balance, kexit_info
DUP3 ISZERO

// If balance is 0, we didn't perform any transfer. Hence, the recipient
// may not exist, and we need to verify this before adding a new journal entry.

// stack: balance=0, address, recipient, balance, kexit_info
%jumpi(skip_journal_entry_if_nonexistent)

sys_selfdestruct_journal_add_after_check:
// stack: address, recipient, balance, kexit_info
%journal_add_account_destroyed
%jump(sys_selfdestruct_exit)

skip_journal_entry_if_nonexistent:
// stack: address, recipient, balance, kexit_info
DUP2 %is_non_existent

// If the account doesn't exist, there is no need to add a journal entry.
// stack: recipient_is_non_existent, address, recipient, balance, kexit_info
%jumpi(skip_journal_entry)

// stack: address, recipient, balance, kexit_info
%jump(sys_selfdestruct_journal_add_after_check)

skip_journal_entry:
// stack: address, recipient, balance, kexit_info
%pop3

sys_selfdestruct_exit:
// stack: kexit_info
%leftover_gas
// stack: leftover_gas
Expand Down

0 comments on commit 4e80f84

Please sign in to comment.