EIP-7684 · Stagnant · Core · 2024-04-12
EIP-7684: Return deposits for distinct credentials
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.
What problem does it solve?
Many 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.
The 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:
- The funder broadcasts a full 32 ETH deposit for the operator's key, with the funder's withdrawal credentials.
- The operator sees it and gets a small deposit for the same key included first, with their own withdrawal credentials.
- The funder's big deposit lands as a top-up to a validator whose withdrawals go to the operator.
Today 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.
How it works
This 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:
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.get_expected_withdrawals: pending withdrawals are returned first, ahead of the normal withdrawal sweep.process_withdrawals: clears the pending-withdrawal queue once paid.
A rejected deposit cannot be refunded in the same block it appears in. After 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.
Sample code
Simplified pseudocode of the deposit rule:
def apply_deposit(state, pubkey, withdrawal_credentials, amount, signature):
index = find_validator_index(state, pubkey)
if index is None:
add_new_validator(state, pubkey, withdrawal_credentials, amount, signature)
return
existing = state.validators[index].withdrawal_credentials
if is_execution_credential(withdrawal_credentials) and withdrawal_credentials != existing:
# EIP-7684: do not top up someone else's validator; send the funds back
refund = amount - RETURN_DEPOSIT_PENALTY
state.pending_withdrawals.append(
Withdrawal(address=withdrawal_credentials[12:], amount=refund)
)
return
increase_balance(state, index, amount) # normal top-up
Things to know
- Status: Stagnant. It has not been scheduled for a hard fork; the front-running risk and the usual workarounds still apply on mainnet.
- It would require a consensus-layer hard fork.
- 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.
- Later changes such as EIP-7251 (consolidations, larger effective balances) and EIP-7002 (execution-triggered withdrawals) changed how deposits and withdrawals interact, so this design would need revisiting before adoption.