
Original title: "Understanding Withdrawals》by Jim McDonald
Original title: "
Withdrawals are the missing part of the validator lifecycle, which has been in development since December 2020 when the Ethereum consensus chain first launched, and will now come with the Shanghai upgrade. Since the Shanghai upgrade will be launched in the first half of this year, it is worth noting and understanding what withdrawal is, how it works, and how to use this new feature.
first level title
history
When the consensus chain first launches in December 2020, you cannot send any information from the consensus chain to the execution chain. In other words, although the balance can be accumulated on the consensus chain, you cannot withdraw cash through the execution chain, because withdrawal is technically impossible at that time. Over the years, the structure of Ethereum has been changed to accommodate new research results, transformed into the current layer 2-centric expansion model, and largely maintained the original appearance of the execution chain. In September 2022, the execution chain merges with the consensus chain, and the execution block becomes a subset of the data in the consensus block. At this point it is feasible to transfer information from the consensus chain to the execution chain, an example of which is validator rewards.
You can find detailed details on how the consensus and execution chains interact and how merged blocks are constructed in the article "Understanding post-merge rewards". The key point is that withdrawals become possible only after the merger.
What are validators doing?
In return for their actions in maintaining the security of the blockchain, these validators are promised rewards directly generated by the Ethereum protocol, recorded on the consensus chain.
first level title
What happened to validator rewards?
An article to understand the working principle of Ethereum pledged withdrawal
Among all validators, the consensus chain has generated more than 1 million ETH as cumulative rewards. In the case of individual validators, their rewards depend on a number of factors, but the most obvious is their time as an active validator. There are many validators who have amassed a large amount of rewards:
Note that since the merge, in addition to the above rewards, validators who propose blocks receive a portion of transaction fees. These fees are paid directly on the execution chain, so they will not be discussed below.
first level title
What did the Shanghai upgrade change?
An article to understand the working principle of Ethereum pledged withdrawal
Figure 3: A withdrawal
The individual components of a withdrawal are:
Withdrawal index A unique identifier for a withdrawal for easy reference.
Validator index (Validator index) The index of the validator of a withdrawal source on the consensus chain
Address (Address) The address where withdrawals will be funneled
When a block is imported into the execution chain, the withdrawal will be processed according to the given amount, and the balance of the corresponding address will increase. Note that withdrawals are not transactions, they do not consume gas, and they do not trigger any smart contract operations at the withdrawal address. Once a block has been processed, the corresponding balance will increase, but nothing else will happen.
first level title
Where did the withdrawn ETH come from?
The above information describes what a withdrawal is, but where does the ETH come from when the withdrawal occurs?
Withdrawals are paid with funds generated according to the Ethereum protocol (i.e. newly minted ETH), rather than transferred from existing accounts. This ensures that withdrawals can always be paid out, even if the total amount withdrawn from the consensus chain is higher than the total amount deposited.
first level title
Withdrawal Clock
An article to understand the working principle of Ethereum pledged withdrawal
The individual components of each validator entity are:
Index (Index) The unique index corresponding to this validator and its position in the list
State (State) The current state of the validator, such as "active" or "exiting" (Note 7)
Balance (Balance) The current balance of the validator, in Gwei
Withdrawal credentials (Withdrawal credentials) The validator's withdrawal credentials
Most of these concepts above are self-explanatory, however withdrawal vouchers require some explanation. Each validator has a set of withdrawal credentials. These credentials control the flow of consensus layer funds, including initial deposits and subsequent rewards.
There are currently two withdrawal certificates:
Generated from a BLS public key, known as a "type 0" withdrawal credential
Generated from the execution address, it is called a "type 1" withdrawal certificate.
We’ll explore these concepts in more detail later, but for now the big difference is that type 1 withdrawal tokens allow consensus funds to be withdrawn to the execution chain, whereas type 0 withdrawal tokens do not.
An article to understand the working principle of Ethereum pledged withdrawal
Chart 4 Withdrawal clock
Once the Shanghai upgrade goes live, the block will contain withdrawal information. In order to select which validators can withdraw, the clock hands rotate around the validators, and each time it points to a validator who is eligible to withdraw, some or all of the validator's balance will be withdrawn according to the following rules:
If the validator has a type 1 certificate, is in the "active" state (Note 8), and has a balance of more than 32 ETH, then the part exceeding 32 ETH will be withdrawn.
If the validator has a type 1 credential and is in the "withdrawable" state with a non-zero balance, then all remaining balances will be withdrawn.
If one of the above rules applies, a withdrawal is made and added to the block; if neither of the above applies, the validator is deemed ineligible and the pointer continues to go down. The pointer will continue to jump until it finds 16 qualified verifiers (Note 9). At this time, the number of withdrawals required for a single block is sufficient, and the withdrawal information will be included in the block.
There are approximately 520,000 active validators at the time of writing. With 16 withdrawals per block and 7,200 blocks per day, it will take about 4.5 days to process each round of eligible validator sets. But as the graph above shows, this time will change as the number of eligible validators changes.
first level title
Procedure for Amending Withdrawal Voucher
An article to understand the working principle of Ethereum pledged withdrawal
Diagram 6: Operation of modifying withdrawal certificate
The components of the operation are:
Validator index The index of the validator to which this operation applies
Withdrawal BLS public key (Withdrawal BLS public key) The BLS public key of the current BLS withdrawal certificate
Execution address Execution address for new withdrawal vouchers
Signature A signature made by the private key of the current BLS withdrawal credential on other fields of the operation.
The operation process on the beacon chain is as follows:
"For each validator defined by the validator index, check whether the given BLS public key can be converted to a type 0 withdrawal certificate matching the current validator. If so, convert the given execution address to type 1's withdrawal credentials and updated for validators."
Therefore, the operation to modify a credential can only occur once. Once the modification of the credential is processed, the definition of the on-chain validator will include a type 1 withdrawal credential, so there will be no type 0 withdrawal credential to match as described above. That is, once a type 1 credential is set, it will remain unchanged during its lifetime. (Note 11)
Select execution address
The first step in modifying the withdrawal certificate is to select the Ethereum execution address to receive the withdrawal. As described above, you can only make one change, so you must ensure that you have secured control of the address private key before making the settings. If you have multiple validator identities then you need to consider whether to provide a different withdrawal address for each validator identity, or use the same address for all validator identities:
It is convenient for you to set the same address, and the rewards will be accumulated to this address faster, so the gas consumed will be less.
Setting up different addresses and keeping them unrelated increases the security of your validator identity, if these validator identities are not related to each other (different savings addresses, different or non-existent block proposal graffiti wait)
create operation
Once an execution address is selected, an operation needs to be created and signed for each validator. Due to the sensitivity of exposing private information related to withdrawal credentials (could be private keys or seed phrases), we recommend offline creation. How to do this is beyond the scope of this article, but you can refer to the detailed guide for doing so using the ethdo tool, or use other tools and wizards that will become available in the future.
After creating operations, you need to broadcast them on the consensus chain. If the operation is provided to the consensus node after the Shanghai upgrade, it will be broadcast to the network at the next opportunity to be packaged into the block. If the operation was provided to the consensus node before the Shanghai upgrade, it will be stored and broadcast to the network after the upgrade is complete. Note that this requires you to be connected to a consensus node that recognizes the Shanghai upgrade; as of right now these consensus nodes are expected to be available sometime in February, giving a good time for the mainnet upgrade.
first level title
Online/Offline Process
An article to understand the working principle of Ethereum pledged withdrawal
Figure 7: Create and broadcast modify withdrawal voucher operations in online and offline configurations
There are quite a few tools that follow this process. For example, ethdo has their own documentation explaining how to do this process. The following is an overview of each step, describing its role and significance.
1. Obtain information on the chain
To create a valid signed credential modification operation, you need to obtain different information from the chain, which should be obtained from the chain itself to ensure that it is the correct information. We also recommend getting a list of all current validators. Because it makes it easier to create operations and at the same time verify that the created operations are suitable for validators.
This information comes from an active consensus node, so it needs to be obtained from a computer connected to the Internet. Most entities running validator programs should have access to consensus nodes, but if they delegate the staking process to a facilitator, they should seek to obtain the necessary information from the facilitator.
This will produce a file containing information on the chain. The files themselves will not carry private keys or other sensitive information.
2. Transfer information on the chain
Once the chain information is collected, it needs to be transferred from an online computer to an offline computer. The current common practice is to use USB storage, which allows two computers to transfer information without direct connection. This means that offline computers can be completely disconnected from the Internet, greatly increasing the security of private keys or seed words.
3. Create Credentials Operations
Once the chain information is available on the offline computer, the credential modification operation can be created. This requires access to the seed phrase and private key that created the current withdrawal credentials, so it is more secure to run the process on an offline computer.
The private key and mnemonic may create credentials for multiple verifiers, so the creation process may result in multiple modification operations.
This will produce a file containing the operations to modify the credentials, the file itself will not contain private keys or other sensitive information.
4. Transfer certificate modification operation
Once the file for the credential modification operation has been created, it needs to be transferred from the offline computer to the online computer. Again, USB storage or similar is a general best practice.
5. Broadcast credential modification operation
first level title
Summarize
Summarize
The withdrawal function will be rolled out with the Shanghai upgrade, making consensus rewards available to users for the first time since the launch of the consensus chain. Once set up, they are automatically available to any validator, and the upgrade also brings a mechanism to configure validators that are not yet ready to withdraw.
After the validator life cycle is completed, the consensus chain fulfills the promise made to the pledgers since December 2020, and allows the validators to leave the system that they thought they might not be able to leave. Additional validators will bring stronger security and a stronger chain to Ethereum.
1. There are multiple chains in Ethereum, usually called the consensus chain (or beacon chain) and the execution chain. For more information, please refer to the article "Understanding Merged Rewards".
2. They also participate in sync committees, but these are just another form of witnessing.
3. It is to use common sayings to explain the migration of Ethereum from the proof-of-work consensus mechanism to the proof-of-stake consensus mechanism.
4. Simultaneously with the Capella upgrade on the consensus chain.
5. Strictly speaking, the maximum number of withdrawals can reach 16, except for extreme cases, all slots should be full.
6. All values on the consensus chain are in Gwei, so any token transfer from the consensus chain to the execution chain is an integer in Gwei.
7. The state actually comes from other fields in the validator info, so it doesn't show up in the validator definition, but since it's referenced elsewhere in the article, it's shown here.
8. For the status definitions of "active" and "withdrawable", please refer to the article "Understanding the validator life cycle"
9. After 16384 validators, the hand of the withdrawal clock will stop beating, even if there are not enough 16 qualified validators, although this is unlikely to happen outside the testnet.
10. The number was actually around 7160 at the time of writing, as some blocks were not proposed or became orphaned after being proposed.
11. This may change in the future as new operations are introduced, but at the time of writing there are no such plans.
12. It is expected that there will be an initial peak of validators modifying their credentials in the first few days after the upgrade, after which there will be very few people queuing as most validators who are eligible to modify their credentials have already done so.
Click "Read the original text" to get the internal link of the article!