-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement EIP-6780 "SELFDESTRUCT" (#735)
Implement the EIP-6780 "SELFDESTRUCT only in same transaction". https://eips.ethereum.org/EIPS/eip-6780 This EIP changes the functionality of the `SELFDESTRUCT` instruction. The new functionality will be only to send all Ether in the account to the beneficiary, except that the current behavior is preserved when `SELFDESTRUCT` is called in the same transaction a contract was created.
- Loading branch information
Showing
5 changed files
with
78 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// evmone: Fast Ethereum Virtual Machine implementation | ||
// Copyright 2023 The evmone Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "../utils/bytecode.hpp" | ||
#include "state_transition.hpp" | ||
|
||
using namespace evmc::literals; | ||
using namespace evmone::test; | ||
|
||
TEST_F(state_transition, selfdestruct_shanghai) | ||
{ | ||
rev = EVMC_SHANGHAI; | ||
tx.to = To; | ||
pre.insert(*tx.to, {.balance = 0x4e, .code = selfdestruct(0xbe_address)}); | ||
|
||
expect.post[To].exists = false; | ||
expect.post[0xbe_address].balance = 0x4e; | ||
} | ||
|
||
TEST_F(state_transition, selfdestruct_cancun) | ||
{ | ||
rev = EVMC_CANCUN; | ||
tx.to = To; | ||
pre.insert(*tx.to, {.balance = 0x4e, .code = selfdestruct(0xbe_address)}); | ||
|
||
expect.post[To].balance = 0; | ||
expect.post[0xbe_address].balance = 0x4e; | ||
} | ||
|
||
TEST_F(state_transition, selfdestruct_to_self_cancun) | ||
{ | ||
rev = EVMC_CANCUN; | ||
tx.to = To; | ||
pre.insert(*tx.to, {.balance = 0x4e, .code = selfdestruct(To)}); | ||
|
||
expect.post[To].balance = 0x4e; | ||
} | ||
|
||
TEST_F(state_transition, selfdestruct_same_tx_cancun) | ||
{ | ||
rev = EVMC_CANCUN; | ||
tx.value = 0x4e; | ||
tx.data = selfdestruct(0xbe_address); | ||
pre.get(Sender).balance += 0x4e; | ||
|
||
expect.post[0xbe_address].balance = 0x4e; | ||
} |