Skip to content

Discard a legacy deposit that names another owner, and charge legacy deposits churn - #994

Open
tcoratger wants to merge 1 commit into
lambdaclass:pq-devnet-2from
tcoratger:fix/pq-legacy-deposit-credentials
Open

tcoratger wants to merge 1 commit into
lambdaclass:pq-devnet-2from
tcoratger:fix/pq-legacy-deposit-credentials

Conversation

@tcoratger

Copy link
Copy Markdown

🗒️ Description / Motivation

This follows ethereum/consensus-specs#5937 ahead of its merge.

A legacy deposit (a 48-byte key whose first 16 bytes are not zero) is credited to the XMSS key keccak256(P ++ 0x00) derived from its BLS key P.
Anyone can compute that key and make a regular deposit for it first:

  1. The attacker deposits 1 ETH for the derived key with the attacker's own withdrawal credentials (or builder execution address).
  2. The victim's legacy deposit for P is processed next and finds that validator (or builder).
  3. It tops up the attacker's validator or builder, and the attacker withdraws the victim's stake.

What Changed

  • stf/epoch/pq.rs, apply_pending_deposit: a legacy deposit for an existing validator whose withdrawal credentials differ from the deposit's is discarded (still removed from the queue).
  • stf/pq.rs, process_builder_deposit_request: a legacy deposit for an existing builder whose execution address differs from withdrawal_credentials[12:] is discarded.
  • stf/epoch/pq.rs, process_pending_deposits: legacy deposits no longer skip the churn; this follows the spec's current churn rule (pq head), where only a deposit for a withdrawn validator is credited without churn.
    Without it, the same front-run deposit would let anyone top up that active validator with legacy deposits outside the churn.

Correctness / Behavior Guarantees

  • A legacy deposit whose credentials (or address) match still tops up the validator (or builder).
  • A legacy deposit for a new validator still creates it and exits it at once; it now waits for churn like any other deposit.
  • Regular (XMSS) deposits are unchanged.

Tests Added / Run

New tests, mirroring the spec PR's:

  • a_legacy_deposit_does_not_top_up_a_validator_with_other_credentials: before, FAILED (balance 33000000000, expected 1000000000); after, ok.
  • a_legacy_builder_deposit_does_not_top_up_a_builder_with_another_address: before, FAILED (balance 2000000000, expected 1000000000); after, ok.
  • a_legacy_deposit_consumes_churn: before, FAILED (validator created: 65 validators, expected 64); after, ok.
  • a_legacy_deposit_tops_up_a_validator_with_the_same_credentials and a_legacy_builder_deposit_tops_up_a_builder_with_its_address: ok before and after.

Commands:

  • cargo test -p ethlambda-state-transition --lib -- legacy deposit preregistration: 29 passed, 0 failed
  • cargo clippy -p ethlambda-state-transition --all-targets -- -D warnings: clean
  • cargo fmt -p ethlambda-state-transition -- --check: clean

Related Issues / PRs

✅ Verification Checklist

  • Ran make fmt — clean (cargo fmt -p ethlambda-state-transition only)
  • Ran make lint (clippy with -D warnings) — clean (ethlambda-state-transition only)
  • Ran make test (test-consensus plus test-node, at release-fast) — only the filtered ethlambda-state-transition tests above

🤖 Generated with Claude Code

…deposits churn

A legacy deposit is credited to the XMSS key derived from its BLS key, which
anyone can deposit for first. It now tops up a validator only if their
withdrawal credentials are equal, and a builder only if it names the builder's
execution address. Legacy deposits also consume churn, as in the current spec.

Follows ethereum/consensus-specs#5937.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant