{"eip":7684,"title":"Return deposits for distinct credentials","description":"Automatically withdraw deposits for existing validator records but with distinct execution withdrawal credentials","authors":["Lion (@dapplion)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2024-04-12","discussionsTo":"https://ethereum-magicians.org/t/eip-7684-return-deposits-for-distinct-credentials/19632","repo":"EIPs","label":"EIP-7684","officialUrl":"https://eips.ethereum.org/EIPS/eip-7684","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7684.md","url":"https://eips.huatuo.xyz/eip-7684/","tldr":{"en":"Proposes that a deposit to an existing validator with different withdrawal credentials be automatically returned (minus a penalty) instead of becoming a top-up, closing a deposit front-running attack.","ja":"既存バリデーターに対して異なる出金クレデンシャルで行われたデポジットを、トップアップにせず（ペナルティを差し引いて）自動的に返金する提案。デポジットのフロントランニング攻撃を封じる。","ko":"이미 존재하는 검증자에게 다른 출금 자격 증명(withdrawal credentials)으로 들어온 예치금을 추가 예치로 처리하지 않고 (페널티를 뺀 뒤) 자동으로 돌려주도록 제안한다. 예치금 프론트러닝 공격을 막는다.","zh":"提议：对已有验证者、但提款凭证（withdrawal credentials）不同的存款，不再作为追加存款，而是自动退回（扣除一笔罚金），从而堵住存款抢跑攻击。"},"tags":["staking","deposits","withdrawals","consensus","security"],"explainers":{"en":{"lang":"en","tldr":"Proposes that a deposit to an existing validator with different withdrawal credentials be automatically returned (minus a penalty) instead of becoming a top-up, closing a deposit front-running attack.","tags":["staking","deposits","withdrawals","consensus","security"],"related":[6110,7002,7251],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7684/","markdown":"## What problem does it solve?\n\nMany staking setups split roles: one party runs the validator key, another party supplies the ETH. The funder needs to keep ultimate control of the money through the **withdrawal credentials** attached to the deposit.\n\nThe beacon chain only looks at the validator public key when it processes a deposit. If a validator already exists for that key, any further deposit is treated as a **top-up**, and the withdrawal credentials in the new deposit are ignored. That opens a front-running attack:\n\n1. The funder broadcasts a full 32 ETH deposit for the operator's key, with the funder's withdrawal credentials.\n2. The operator sees it and gets a small deposit for the same key included first, with *their own* withdrawal credentials.\n3. The funder's big deposit lands as a top-up to a validator whose withdrawals go to the operator.\n\nToday people work around this with distributed key generation, or by depositing 1 ETH first and topping up only after it is included. Both add friction, especially for trustless staking protocols. EIP-7684 limits the worst-case loss of a naive deposit to a fixed `RETURN_DEPOSIT_PENALTY`.\n\n## How it works\n\nThis is a consensus-layer-only change; the execution layer is untouched. The detailed rules live in the consensus-specs repository; the EIP summarises them as:\n\n- **`apply_deposit`**: if a deposit targets an existing validator but carries **distinct execution withdrawal credentials**, it is not credited. Instead it is queued as a *pending withdrawal* back to the address in those credentials.\n- **`get_expected_withdrawals`**: pending withdrawals are returned first, ahead of the normal withdrawal sweep.\n- **`process_withdrawals`**: clears the pending-withdrawal queue once paid.\n\nA rejected deposit cannot be refunded in the same block it appears in. After [EIP-6110](/eip-6110/) deposits come from the execution payload, so the execution client would need to know the withdrawals before the deposits that trigger them exist. Rejected deposits are therefore paid out in a following slot; the spec processes all pending ones in the very next slot for simplicity.\n\n## Sample code\n\nSimplified pseudocode of the deposit rule:\n\n```python\ndef apply_deposit(state, pubkey, withdrawal_credentials, amount, signature):\n    index = find_validator_index(state, pubkey)\n    if index is None:\n        add_new_validator(state, pubkey, withdrawal_credentials, amount, signature)\n        return\n\n    existing = state.validators[index].withdrawal_credentials\n    if is_execution_credential(withdrawal_credentials) and withdrawal_credentials != existing:\n        # EIP-7684: do not top up someone else's validator; send the funds back\n        refund = amount - RETURN_DEPOSIT_PENALTY\n        state.pending_withdrawals.append(\n            Withdrawal(address=withdrawal_credentials[12:], amount=refund)\n        )\n        return\n\n    increase_balance(state, index, amount)  # normal top-up\n```\n\n## Things to know\n\n- **Status: Stagnant.** It has not been scheduled for a hard fork; the front-running risk and the usual workarounds still apply on mainnet.\n- It would require a consensus-layer hard fork.\n- The spec notes a cost: the worst-case number of withdrawals per block rises sharply (from a fixed 16 to over a thousand at a 30M gas limit), adding unpriced work to blocks. The penalty is meant to discourage spamming rejected deposits.\n- Later changes such as [EIP-7251](/eip-7251/) (consolidations, larger effective balances) and [EIP-7002](/eip-7002/) (execution-triggered withdrawals) changed how deposits and withdrawals interact, so this design would need revisiting before adoption.\n"},"ja":{"lang":"ja","tldr":"既存バリデーターに対して異なる出金クレデンシャルで行われたデポジットを、トップアップにせず（ペナルティを差し引いて）自動的に返金する提案。デポジットのフロントランニング攻撃を封じる。","tags":["staking","deposits","withdrawals","consensus","security"],"related":[6110,7002,7251],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7684/","markdown":"## 何を解決するのか\n\n多くのステーキング構成では役割が分かれています。バリデーター鍵を運用する側と、ETH を提供する側です。資金提供者は、デポジットに付与される**出金クレデンシャル（withdrawal credentials）**を通じて、資金の最終的な管理権を保持する必要があります。\n\nビーコンチェーンはデポジットを処理するとき、バリデーターの公開鍵だけを見ます。その鍵のバリデーターがすでに存在する場合、以降のデポジットはすべて**トップアップ**として扱われ、新しいデポジットに含まれる出金クレデンシャルは無視されます。これがフロントランニング攻撃の余地を生みます。\n\n1. 資金提供者が、オペレーターの鍵に対して、自分の出金クレデンシャルを付けた 32 ETH 全額のデポジットをブロードキャストします。\n2. オペレーターはそれを見つけ、同じ鍵に対する少額のデポジットを、*自分の* 出金クレデンシャルを付けて先に取り込ませます。\n3. 資金提供者の大きなデポジットは、出金先がオペレーターになっているバリデーターへのトップアップとして着地します。\n\n現状では、分散鍵生成を使うか、最初に 1 ETH だけ預けて取り込まれた後でトップアップするという方法で回避しています。どちらも手間が増え、特にトラストレスなステーキングプロトコルでは負担になります。EIP-7684 は、無防備なデポジットの最悪時の損失を、固定の `RETURN_DEPOSIT_PENALTY` に抑えます。\n\n## 仕組み\n\nこれはコンセンサスレイヤーのみの変更で、実行レイヤーには手を加えません。詳細なルールは consensus-specs リポジトリにあり、EIP では次のように要約されています。\n\n- **`apply_deposit`**: デポジットが既存のバリデーターを対象としていて、かつ**異なる実行レイヤー出金クレデンシャル**を持つ場合、入金されません。代わりに、そのクレデンシャルに含まれるアドレスへの*保留中の出金（pending withdrawal）*としてキューに入れられます。\n- **`get_expected_withdrawals`**: 保留中の出金が、通常の出金スイープより先に返されます。\n- **`process_withdrawals`**: 支払い済みになった時点で、保留中の出金キューをクリアします。\n\n拒否されたデポジットは、それが現れた同じブロック内では返金できません。[EIP-6110](/eip-6110/) 以降、デポジットは実行ペイロードから届くため、実行クライアントは、出金の原因となるデポジットが存在する前にその出金を知っておく必要が出てしまいます。そのため、拒否されたデポジットは後続のスロットで支払われます。仕様では簡単のため、保留中のものをすべて直後のスロットで処理します。\n\n## サンプルコード\n\nデポジットルールを簡略化した擬似コード:\n\n```python\ndef apply_deposit(state, pubkey, withdrawal_credentials, amount, signature):\n    index = find_validator_index(state, pubkey)\n    if index is None:\n        add_new_validator(state, pubkey, withdrawal_credentials, amount, signature)\n        return\n\n    existing = state.validators[index].withdrawal_credentials\n    if is_execution_credential(withdrawal_credentials) and withdrawal_credentials != existing:\n        # EIP-7684: do not top up someone else's validator; send the funds back\n        refund = amount - RETURN_DEPOSIT_PENALTY\n        state.pending_withdrawals.append(\n            Withdrawal(address=withdrawal_credentials[12:], amount=refund)\n        )\n        return\n\n    increase_balance(state, index, amount)  # normal top-up\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** ハードフォークにはスケジュールされておらず、メインネットではフロントランニングのリスクと通常の回避策がそのまま当てはまります。\n- コンセンサスレイヤーのハードフォークが必要です。\n- 仕様にはコストも記されています。1 ブロックあたりの最悪時の出金数が大きく増え（固定の 16 から、ガスリミット 3,000 万で 1,000 超へ）、価格付けされていない処理がブロックに加わります。ペナルティは、拒否されるデポジットによるスパムを抑止するためのものです。\n- [EIP-7251](/eip-7251/)（コンソリデーション、より大きな有効残高）や [EIP-7002](/eip-7002/)（実行レイヤーが起点となる出金）といった後の変更により、デポジットと出金の相互作用が変わったため、採用前にこの設計の見直しが必要になります。\n"},"ko":{"lang":"ko","tldr":"이미 존재하는 검증자에게 다른 출금 자격 증명(withdrawal credentials)으로 들어온 예치금을 추가 예치로 처리하지 않고 (페널티를 뺀 뒤) 자동으로 돌려주도록 제안한다. 예치금 프론트러닝 공격을 막는다.","tags":["staking","deposits","withdrawals","consensus","security"],"related":[6110,7002,7251],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7684/","markdown":"## 어떤 문제를 해결하나요?\n\n많은 스테이킹 구성은 역할을 나눕니다. 한쪽은 검증자 키를 운영하고, 다른 쪽은 ETH를 제공합니다. 자금 제공자는 예치금에 붙는 **출금 자격 증명(withdrawal credentials)**을 통해 자금의 최종 통제권을 유지해야 합니다.\n\n비콘 체인은 예치금을 처리할 때 검증자 공개 키만 봅니다. 해당 키의 검증자가 이미 있으면 이후의 모든 예치금은 **추가 예치(top-up)**로 취급되고, 새 예치금에 담긴 출금 자격 증명은 무시됩니다. 이 때문에 프론트러닝 공격이 가능해집니다.\n\n1. 자금 제공자가 운영자의 키에 대해 자신의 출금 자격 증명을 붙인 32 ETH 전액 예치금을 브로드캐스트합니다.\n2. 운영자가 이를 발견하고, 같은 키에 대한 소액 예치금을 *자신의* 출금 자격 증명과 함께 먼저 포함시킵니다.\n3. 자금 제공자의 큰 예치금은 출금처가 운영자인 검증자에 대한 추가 예치로 반영됩니다.\n\n현재는 분산 키 생성을 쓰거나, 먼저 1 ETH만 예치하고 포함된 뒤에 추가 예치하는 방식으로 우회합니다. 둘 다 번거로움이 늘어나며, 특히 신뢰가 필요 없는 스테이킹 프로토콜에는 부담입니다. EIP-7684는 단순한 예치의 최악 손실을 고정된 `RETURN_DEPOSIT_PENALTY`로 제한합니다.\n\n## 어떻게 동작하나요?\n\n이는 합의 계층만 바꾸는 변경이며 실행 계층은 건드리지 않습니다. 자세한 규칙은 consensus-specs 저장소에 있고, EIP는 이를 다음과 같이 요약합니다.\n\n- **`apply_deposit`**: 예치금이 기존 검증자를 대상으로 하면서 **서로 다른 실행 계층 출금 자격 증명**을 가지고 있으면 입금되지 않습니다. 대신 해당 자격 증명에 담긴 주소로 돌려보내는 *대기 중인 출금(pending withdrawal)*으로 큐에 들어갑니다.\n- **`get_expected_withdrawals`**: 대기 중인 출금이 일반 출금 스윕보다 먼저 반환됩니다.\n- **`process_withdrawals`**: 지급이 끝나면 대기 중인 출금 큐를 비웁니다.\n\n거부된 예치금은 그것이 나타난 같은 블록에서는 환불할 수 없습니다. [EIP-6110](/eip-6110/) 이후 예치금은 실행 페이로드에서 오기 때문에, 실행 클라이언트는 출금을 일으키는 예치금이 존재하기도 전에 그 출금을 알아야 하게 됩니다. 그래서 거부된 예치금은 이후 슬롯에서 지급됩니다. 명세는 단순함을 위해 대기 중인 항목을 모두 바로 다음 슬롯에서 처리합니다.\n\n## 샘플 코드\n\n예치 규칙의 단순화한 의사 코드:\n\n```python\ndef apply_deposit(state, pubkey, withdrawal_credentials, amount, signature):\n    index = find_validator_index(state, pubkey)\n    if index is None:\n        add_new_validator(state, pubkey, withdrawal_credentials, amount, signature)\n        return\n\n    existing = state.validators[index].withdrawal_credentials\n    if is_execution_credential(withdrawal_credentials) and withdrawal_credentials != existing:\n        # EIP-7684: do not top up someone else's validator; send the funds back\n        refund = amount - RETURN_DEPOSIT_PENALTY\n        state.pending_withdrawals.append(\n            Withdrawal(address=withdrawal_credentials[12:], amount=refund)\n        )\n        return\n\n    increase_balance(state, index, amount)  # normal top-up\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** 하드 포크 일정이 잡혀 있지 않으며, 메인넷에서는 프론트러닝 위험과 일반적인 우회 방법이 그대로 적용됩니다.\n- 합의 계층 하드 포크가 필요합니다.\n- 명세는 비용도 언급합니다. 블록당 최악의 출금 수가 크게 늘어(고정 16개에서 가스 한도 3,000만 기준 1,000개 이상으로), 가격이 매겨지지 않은 작업이 블록에 추가됩니다. 페널티는 거부되는 예치금으로 스팸을 보내는 것을 막기 위한 것입니다.\n- [EIP-7251](/eip-7251/)(통합, 더 큰 유효 잔액)과 [EIP-7002](/eip-7002/)(실행 계층에서 시작하는 출금) 같은 이후 변경으로 예치와 출금이 상호작용하는 방식이 바뀌었으므로, 채택 전에 이 설계를 다시 검토해야 합니다.\n"},"zh":{"lang":"zh","tldr":"提议：对已有验证者、但提款凭证（withdrawal credentials）不同的存款，不再作为追加存款，而是自动退回（扣除一笔罚金），从而堵住存款抢跑攻击。","tags":["staking","deposits","withdrawals","consensus","security"],"related":[6110,7002,7251],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7684/","markdown":"## 它解决什么问题？\n\n许多质押方案会拆分角色：一方运行验证者密钥，另一方提供 ETH。出资方需要通过存款所附带的**提款凭证（withdrawal credentials）**，保留对资金的最终控制权。\n\n信标链处理存款时只看验证者公钥。如果该公钥对应的验证者已经存在，之后的任何存款都会被视为**追加存款（top-up）**，新存款中的提款凭证会被忽略。这就留下了抢跑攻击的空间：\n\n1. 出资方为运营者的密钥广播一笔完整的 32 ETH 存款，使用出资方自己的提款凭证。\n2. 运营者看到后，抢先让一笔针对同一密钥的小额存款被打包，使用*他自己的*提款凭证。\n3. 出资方的大额存款最终作为追加存款，落到一个提款地址属于运营者的验证者上。\n\n目前人们的变通办法是使用分布式密钥生成，或者先存入 1 ETH，等它被打包后再追加。两种做法都增加了麻烦，对无需信任的质押协议尤其如此。EIP-7684 把朴素存款的最坏损失限制在固定的 `RETURN_DEPOSIT_PENALTY` 以内。\n\n## 它如何运作\n\n这只是共识层的改动，执行层不受影响。详细规则位于 consensus-specs 仓库；EIP 将其概括如下：\n\n- **`apply_deposit`**：如果存款指向已有验证者，但带有**不同的执行层提款凭证**，则不会入账，而是作为*待处理提款（pending withdrawal）*排入队列，退回到这些凭证中的地址。\n- **`get_expected_withdrawals`**：待处理提款先于常规的提款扫描返回。\n- **`process_withdrawals`**：支付完成后清空待处理提款队列。\n\n被拒绝的存款无法在它出现的同一个区块中退款。在 [EIP-6110](/eip-6110/) 之后，存款来自执行负载，因此执行客户端需要在触发提款的存款存在之前就知道这些提款。所以被拒绝的存款会在之后的 slot 中支付；为简单起见，规范在紧接着的下一个 slot 处理所有待处理项。\n\n## 示例代码\n\n存款规则的简化伪代码：\n\n```python\ndef apply_deposit(state, pubkey, withdrawal_credentials, amount, signature):\n    index = find_validator_index(state, pubkey)\n    if index is None:\n        add_new_validator(state, pubkey, withdrawal_credentials, amount, signature)\n        return\n\n    existing = state.validators[index].withdrawal_credentials\n    if is_execution_credential(withdrawal_credentials) and withdrawal_credentials != existing:\n        # EIP-7684: do not top up someone else's validator; send the funds back\n        refund = amount - RETURN_DEPOSIT_PENALTY\n        state.pending_withdrawals.append(\n            Withdrawal(address=withdrawal_credentials[12:], amount=refund)\n        )\n        return\n\n    increase_balance(state, index, amount)  # normal top-up\n```\n\n## 需要注意\n\n- **状态：Stagnant。**尚未排入任何硬分叉；主网上抢跑风险和常见的变通办法依然适用。\n- 需要一次共识层硬分叉。\n- 规范指出了一项代价：每个区块最坏情况下的提款数量会大幅上升（在 3000 万 gas 上限下，从固定的 16 个增至一千多个），给区块增加了未定价的工作量。罚金旨在抑制利用被拒绝存款发送垃圾交易的行为。\n- 之后的变更，例如 [EIP-7251](/eip-7251/)（合并、更大的有效余额）和 [EIP-7002](/eip-7002/)（由执行层触发的提款），改变了存款与提款之间的相互作用，因此该设计在采用前需要重新审视。\n"}}}
