---
eip: 6046
label: EIP-6046
title: Replace SELFDESTRUCT with DEACTIVATE
status: Stagnant
type: Standards Track
category: Core
created: 2022-11-25
requires: 2681, 2929, 3529
official: https://eips.ethereum.org/EIPS/eip-6046
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-6046.md
canonical: https://eips.huatuo.xyz/zh/eip-6046/
lang: zh
tldr: 一个已停滞的提案：把 SELFDESTRUCT 改为 DEACTIVATE，保留账户及其存储，将余额清零并用特殊 nonce 标记，这样该 opcode 就不必再删除数量无上限的状态。
tags: [selfdestruct, evm, opcode, state, verkle, core]
---

# EIP-6046: Replace SELFDESTRUCT with DEACTIVATE

> Change SELFDESTRUCT to not delete storage keys and use a special value in the account nonce to signal deactivation

**TL;DR:** 一个已停滞的提案：把 SELFDESTRUCT 改为 DEACTIVATE，保留账户及其存储，将余额清零并用特殊 nonce 标记，这样该 opcode 就不必再删除数量无上限的状态。

## 它解决什么问题？

`SELFDESTRUCT` 过去会以固定的 gas 价格删除合约的代码和**全部**存储。由于合约可以有任意数量的存储槽，它引起的工作量是无上限的。它还与 Verkle 树冲突：在 Verkle 树中每个存储槽都有自己的键，没有切实可行的办法找出并删除一个账户用过的每个键。

许多提案干脆取消了删除。EIP-6046 尝试了一条折中的路：让"销毁后再在同一地址重新部署"的模式继续可用，而不必清除存储。

## 它如何运作

- [EIP-2681](/eip-2681/) 的账户 nonce 上限降低 1，变为 `2^64-2`，从而使 `2^64-1` 成为空闲的标记值（从创世起适用）。
- `SELFDESTRUCT` 改名为 **`DEACTIVATE`**，现在的行为是：
  - 把余额发送给受益人，并将账户余额设为 0；
  - **不会**删除代码或存储，账户保留原位；
  - 把 nonce 设为 `2^64-1`，将该账户标记为已停用。
- 调用已停用的账户（通过交易或 `CALL*`）会立即成功并返回空数据。它仍可接收普通的 ETH 转账。
- 允许在 nonce 为 `2^64-1` 的账户上执行 `CREATE2`。新代码会替换旧代码，但**旧存储仍然保留**。
- 不提供 gas 退款（相关退款已被 [EIP-3529](/eip-3529/) 移除），[EIP-2929](/eip-2929/) 的访问规则不变。

改名表明"复活"不再给你一张白纸。

## 示例代码

所提议行为的伪代码：

```python
DEACTIVATED = 2**64 - 1

def op_deactivate(evm, beneficiary):
    acct = evm.state[evm.address]
    evm.state[beneficiary].balance += acct.balance
    acct.balance = 0
    acct.nonce = DEACTIVATED        # code and storage are left untouched

def execute_call(state, addr, ...):
    if state[addr].nonce == DEACTIVATED:
        return Success(output=b"")  # value transfers still credited

def create2_allowed(state, addr):
    a = state[addr]
    return a.nonce == DEACTIVATED or (a.nonce == 0 and not a.code)
```

按此规则打算被复活的合约，必须把已有存储视为可能已经过期：

```solidity
// On re-deploy, slots written by the previous incarnation may still be set.
uint256 public generation;
function init() external { generation += 1; /* key new data by generation */ }
```

## 需要注意

- **状态：Stagnant。** 它从未被排入网络升级计划。
- 以太坊转而采用了 [EIP-6780](/eip-6780/)（Dencun 升级）：只有在创建合约的同一笔交易中调用 `SELFDESTRUCT` 时才会删除账户，否则它只会发送余额。一个相关的早期想法是 [EIP-4758](/eip-4758/)。
- 如果采用类似方案，自毁后重新部署的合约就需要处理遗留的存储，规范将此标记为安全隐患。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-6046
