The Art of War on Proof-of-Stake Ethereum
As the success of The Merge has brought Ethereum to the Proof-of-Stake consensus, the staking mechanism has changed many facets of the Ethereum community of validators. In theory, PoS Ethereum is superior in energy saving and decentralization compared with the former PoW Ethereum, preserving security in the consensus-building process by blockchain validation. However, reality speaks louder in data visualizations. In this project, we implemented several visualizations of the validator life cycle based on Ethereum blockchain execution and consensus layer data for exploratory research of PoS Ethereum consensus decentralization and security.
With the success of The Merge, Ethereum has finished the joining of the execution layer and the consensus layer, the Beacon Chain, upgrading from the Proof-of-Work (PoW) consensus to Proof-of-Stake (PoS) consensus. The staking mechanism in the PoS Ethereum miners on the Ethereum consensus layer into validators. The validators stake ethers (ETH) into a smart contract, contributing to the PoS consensus. We elaborate on the life cycle of a validator and how a validator takes part in the Ethereum PoS consensus.
Figure 1 shows the block finalization rate before and after The Merge. The x-axis shows the time series, while the y-axis shows the time of block finalization in seconds. The block finalization rate is stable between 13-13.5 seconds per block during 2021 and the first half of 2022. It peaked in June 2022 and dropped sharply at the beginning of July. After The Merge, the average block finalization time drops to 12 seconds per block.
The staking mechanism on the PoS Ethereum contributed essentially to the change of block finalization duration after the merge. On the previous PoW Ethereum, miners compete in computing the hash code to mine a block, where the block finalization duration depends mainly on the computing powers. In contrast, on the PoS Ethereum, the finalization happens during the validation of transactions in a block, which occurs in a slot of 12 seconds. Thus, in facets of blockchain building and finalization, the PoS mechanism brings much efficiency to Ethereum. First, the new staking mechanism reduces the energy waste caused by mining. Second, the new validation process improves efficiency in the block finalization rate, contributing to scalability by accelerating the block-building process. Validators are the casting stars of the PoS Ethereum. Below, we introduce further the life cycle and contribution of validators in the PoS consensus.
Figure 2 shows a generalized validator life cycle on the PoS Ethereum blockchain. According to Ethereum notes and Ethereum Developer Docs, validators are in one of the six states: 1) deposited, 2) eligible to be activated (pending), 3) activated, 4) slashed, 5) exited, and 6) withdrawable. The PoS Ethereum times in slots, each of 12 seconds, and epochs, each epoch of 32 slots (6.4 mins). Ethereum updates the state of validators by epoch (s) following the rules below.
Deposited: after paying the deposit fee of 32 ETH, the validator becomes deposited
Eligible to be activated: the first step in the epoch-processing is to check whether the validator is eligible to be added to the activation queue. The activation queue locates validators who are eligible for activation but are not activated yet.
Activated: for validators entering the activation queue after one epoch, if checked to be eligible for activation, the validators would be activated after four epochs. Once activated, the validators are able to participate in the PoW consensus process.
Slashed: the validator misbehaving and caught by other validators are slashed.
Exited: the validators are exited if they are slashed or have an insufficient balance due to large penalties or volunteer to exit.
Withdrawable: the unslashed (and exited) validators have a lock-in period of 28 epochs (~27 hours) to become withdrawable; in contrast, the slashed (and exited) validators need to wait from 213 epochs (~36 days) before they become withdrawable.
Validators propose and validate blocks on the PoS Ethereum blockchain. At each epoch, the mechanism randomly selects validators into proposers and a committee of attesters. In each slot, the proposer proposes a block, and the committee votes for the validity of the proposed block.
However, how the merge changes Ethereum, in reality, is not visible to the public. Reality speaks louder in data visualizations. Thus, we implement three visualizations of the beacon chain before and after the merge so that the general public would be able to infer the answer to three important research questions.
RQ1 (the casting stars): What is the time series distribution of validators’ life cycles on Ethereum?
RQ2 (consensus decentralization): How decentralized is the voting mechanism in the Proof-of-Stake Ethereum?
RQ3 (consensus security): How does the staking mechanism prevent malicious behaviors?
Our research goals are to:
Help our audience understand how proof-of-stake Ethereum works by visualizing the life cycle of the casting star, the validators.
Verify the decentralization in PoS Ethereum by visualizing the validators’ voting process.
Examine the power of the staking mechanism in improving consensus security by showing the change in the number of slashed validators before and after The Merge.
Data and Code Availability: The data, code, and visualizations are available on GitHub: https://github.com/SciEcon/ethereum-beaconchain
For RQ1, we draw a river plot to show the times series distribution of validators in different states of their life cycles.
Query Data: We retrieved validator information using the web3py library. The data consists of information on 427927 validators. Figure 3 shows a validator data entry example.
Process Data: To clarify our findings, we focus on three main periods in a validator’s life cycle: 1) being eligible for activation, 2) being activated, and 3) being exited. The raw data consists of the epochs for which a validator was eligible-to-activate, activated, withdrawable, or exited. From these, we aggregated the validator data entry daily, resulting in Table 1.
Attribute Name | Description | Example |
date | The time that the data is observed. | 2022-10-24 |
index | The identifier of the validator. | 155813 |
eligible | The number of validators that are eligible for activation but not activated yet. | 849 |
activated | The number of validators that are activated. | 426067 |
exited | The number of validators that are exited. | 812 |
Table 1: The features and descriptions of data for RQ1.
For RQ2, we draw a chord graph that connects block attestors to the proposer.
Query Data: For this purpose, we collected two sets of data:
The first dataset is the beacon chain block data ranging from Slot No. 4680000 to 4720000 (40001 blocks in total). I retrieved the data using the ethereum2-etl library. Figure 4 shows a block data entry example. For each block, we retrieved the identity of the block proposer and epoch committees (attestors) index using the variables of proposer_index and attestations, respectively.
The second dataset documents the epoch committees for each corresponding block. We retrieve the data using get_epoch_committees API from web3py library. We provide an epoch committee data entry example item in Figure 5.
For RQ3, we draw two line charts to illustrate and compare the block time and slashing conditions before and after the merge. We retrieved two datasets:
Dataset 1: We query block time history data from etherescan public dashboard. Figure 6 shows the example data.
Dataset 2: We retrieved the validator data using the ethereum2-etl library. The data structure is similar to Table 1. We calculate the time series of (accumulated) validators being slashed and their effective balance.
Figures 7, 8, and 9 show the time series distribution of validator life cycles in screenshots of the river plot. The Figures demonstrate the changes in the amount of eligible-for-activation (green area) activated (blue area) and exited (yellow) validators from Dec. 4th, 2020, to Oct. 28th, 2022. Figure 10 demonstrates the same distribution in an area plot. From the figure, we have two observations:
the number of activated validators is increasing stably
there are four periods in the history when the number of new eligible participants increased sharply: 12/04/2020–03/06/2021, 05/03/2021–07/20/2021, 08/16/2021–09/21/2021, and 03/01/2022–05/31/2022.
The Interactive Graph in HTML: https://sciecon.github.io/river/
Figures 11 and 12 are Splitchord graphs for the attestation count in block-building for 100 slots before and after the merge respectively. This chord graph connects the block proposer to the number of attestations in the slot of the block proposer. The left side represents the index of the block proposer in a slot. And the right side represents the number of attestations submitted by validators in this slot. Figures 11 and 12 show that after the merge, more slots reached the max attestation count of 128. The Ethereum Beacon chain consensus involves 500,000 (source: https://beaconcha.in/validators active validators with each 12-second slot of 64 sub-committees and each committee of 207 or 208 validators. Such a large number of involvement is marvelous historically in the validation process in a distributed system. However, we are not able to conclude whether the process is decentralized or not due to the anonymity of validators on Ethereum, i.e. theoretically, we cannot distinguish the scenario that 500,000 persons are behind or 1 person behind the 500,000 validators. We leave the further evaluation of decentralization for future research.
Figures 13 and 14 show the time series of the (accumulated) slashed validators and their balance, in ETH, before and after the Merge. The x-axis demonstrates the timeline from late 2020 to Oct. 2022; The (left) right y-axis illustrates the number of (accumulated) slashed validators on-chain. Figure 13 evidences a sharp increase in the accumulated number of slashed validators from Feb. 2nd, 2021, to Feb. 6th, 2021. The number of slashed validators oscillated before the merge, soared right after the merge, and then decreased to and stayed around zero. Our results imply an increased consensus security on PoS Ethereum after the merge.
In conclusion, on the PoS Ethereum, stakeholders contribute to the consensus-building process by staking 32 ETH and acting as validators. Theory speaks: PoS Ethereum is superior in energy saving and decentralization compared with the former PoW Ethereum, preserving security in the consensus-building process by blockchain validation. How about the reality? Our visualization speaks louder: the merge evidences an improvement in consensus decentralization and security.
Let this be our last word. The staking mechanism in PoS Ethereum resonates with the wisdom in the Art of War:
Thus the highest form of generalship is to balk at the enemy's plans; the next best is to prevent the junction of the enemy's forces; the next in order is to attack the enemy's army in the field, and the worst policy of all is to besiege walled cities. (Original text in Chinese: 故上兵伐謀,其次伐交,其次伐兵,其下攻城.)
In similar spirits, the highest form of slashing is to incentivize the players not to be slashed at all…