How is my ETH deposit processed? [Part 1 of Staking at Ethereum]

How is my ETH deposit processed? [Part 1 of Staking at Ethereum]
Photo by PiggyBank / Unsplash
As Ethereum continues to evolve, so does its staking mechanism. This is the first article of the Staking at Ethereum series. This article addresses the end-to-end process of staking, from initial deposit to eventual withdrawal.

A key feature of Ethereum’s PoS System is staking. By staking funds, users can actively contribute to the network's security. What's particularly interesting is that anyone can participate in the PoS network without needing special permission.

So, how is an ETH deposit processed when someone decides to stake in the Ethereum protocol? Let’s explore each step by following Alice’s journey—from staking 32 ETH to becoming a validator and eventually unstaking her funds.

Step 1: Deposit

Alice sends a deposit transaction to the Deposit Contract on the execution layer (EL) with 32 ETH. The address of Deposit Contract for Ethereum mainnet is 0x00000000219ab540356cBB839Cbe05303d7705Fa.

Little hippo welcomes a solo staker!
/// @notice Submit a Phase 0 DepositData object.
/// @param pubkey A BLS12-381 public key.
/// @param withdrawal_credentials Commitment to a public key for withdrawals.
/// @param signature A BLS12-381 signature.
/// @param deposit_data_root The SHA-256 hash of the SSZ-encoded DepositData object.
/// Used as a protection against malformed input.
function deposit(
    bytes calldata pubkey,
    bytes calldata withdrawal_credentials,
    bytes calldata signature,
    bytes32 deposit_data_root
) external payable;

deposit method looks like...

The deposit method requires a bunch of data related to her validator, so she needs to generate a new key pair responsible for signing on the consensus layer (CL). For a user who is familiar with command line interfaces, staking-deposit-cli provides a convenient way to generate a mnemonic and build the deposit data to be included in the deposit tx. The deposit message must be signed with her secret key, which generates the deposit data. Once the transaction is included, the Deposit Contract emits a Deposit event and a corresponding receipt.

When generating deposit data, Alice can also set her wallet address to receive partial withdrawals during the staking lifecycle. This can be configured after validator activation by sending a BLS-to-execution change message to the CL, but for simplicity, let's assume Alice has set the eth1 withdrawal credentials correctly during the initial setup.

Step 2: Bridging Deposit to Consensus Layer

Step 2 involves bridging the deposit message from the EL to the CL, where the Eth1 voting process is used. This mechanism, introduced during Ethereum's Proof-of-Work phase, ensures that the execution layer’s state is accurately relayed to the consensus layer. In this process, CL proposers include their view of the EL state in each block. Once more than half of the blocks include the same view, the CL considers deposits up to a specific block number valid and ready for processing. After the CL applies the deposit, Alice’s deposit data undergoes a more secure validation, including signature verification, which was skipped at the EL level.

To ensure that the PoW Ethereum chain is finalized adequately, Alice should wait at least 8 hours for her deposit to be processed. ETH1_FOLLOW_DISTANCE is a preset value related to this phenomenon. (See consensus-specs) It's quite interesting that the 8-hour delay fits a general sleep cycle, so Ethereum devs can respond to any attack or bug.

However, Eth1 voting has become a form of technical debt for all consensus clients nowadays. Due to the Merge, Eth1 voting has become less relevant. With the execution payload now included in the beacon block, the CL no longer has reason to wait 8 hours to process newer deposits.. EIP-6110 (Supply validator deposits on-chain) addresses this issue, gradually deprecating Eth1 voting process. The next consensus upgrade, Electra, is confirmed to include EIP-6110.

Step 3: Validator Lifecycle

A validator has a lot to do in his lifecycle...

In Step 3, Alice’s validator becomes active after passing through the activation queue. Once active, it is assigned various duties in the consensus process, such as block proposals, attestation, and participation in sync committees. (Hope sometimes I addresses the To-Do list for validator) Based on its performance, Alice’s validator earns rewards for successfully completing duties or penalties for failing attestation duties, which are reflected in her balance on the CL.

Post-Capella, partial withdrawals are enabled. By sweeping through the active validator registry, the system automatically withdraws eligible validators’ balances to the EL. This process, though similar to full withdrawal, will be further explained in Step 4.

Step 4: Unstaking and Withdrawal

Step 4 is initiated when Alice decides to unstake. In the current version of the protocol(Deneb), Alice must send a voluntary exit message to the CL. After sending the exit message, her validator must wait in the exit queue (similar to the activation queue). While waiting, Alice’s validator remains active and must continue performing its duties. Once her validator reaches the exit epoch, Alice must wait for an additional period (at least 256 epochs, over 25 hours) before she can withdraw her funds.

The CL processes withdrawals for eligible validators, with each block proposer including a list of withdrawals that lead to balances being added to the corresponding addresses on the EL.

In Electra, it is also confirmed to include EIP-7002. EIP-7002 (Execution layer-triggerable withdrawals) will enable validators to initiate their exits and withdrawals through an EL transaction, offering a faster, more flexible way to unstake compared to the current voluntary exit process handled solely by the consensus layer.

Outro

As Vitalik said, solo stakers are key to the security of the Ethereum protocol. But, the introduction of the beacon chain and PoS mechanism to Ethereum has brought some UX degradation. Electra is the first major upgrade in the Ethereum consensus protocol, and I'm really looking forward to the impact of the new staking mechanism. consensus-specs for Electra keeps changing frequently, and you can keep up with those updates on my blog.

More reads

  • eth2book is the best resource to study an overview of consensus protocol.
  • EIP-6110 and EIP-7002 will highly increase UX for stakers.