HackMD
    • Sharing Link copied
    • /edit
    • View mode
      • Edit mode
      • View mode
      • Book mode
      • Slide mode
      Edit mode View mode Book mode Slide mode
    • Note Permission
    • Read
      • Only me
      • Signed-in users
      • Everyone
      Only me Signed-in users Everyone
    • Write
      • Only me
      • Signed-in users
      • Everyone
      Only me Signed-in users Everyone
    • More (Comment, Invitee)
    • Publishing
    • Commenting Enable
      Disabled Forbidden Owners Signed-in users Everyone
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Invitee
    • No invitee
    • Options
    • Versions and GitHub Sync
    • Transfer ownership
    • Delete this note
    • Template
    • Save as template
    • Insert from template
    • Export
    • Google Drive Export to Google Drive
    • Gist
    • Import
    • Google Drive Import from Google Drive
    • Gist
    • Clipboard
    • Download
    • Markdown
    • HTML
    • Raw HTML
Menu Sharing Help
Menu
Options
Versions and GitHub Sync Transfer ownership Delete this note
Export
Google Drive Export to Google Drive Gist
Import
Google Drive Import from Google Drive Gist Clipboard
Download
Markdown HTML Raw HTML
Back
Sharing
Sharing Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
More (Comment, Invitee)
Publishing
More (Comment, Invitee)
Commenting Enable
Disabled Forbidden Owners Signed-in users Everyone
Permission
Owners
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Invitee
No invitee
   owned this note    owned this note      
Published Linked with GitHub
Like BookmarkBookmarked
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# A note on Ethereum 2.0 phase 0 validator lifecycle ###### tags: `eth2` `v0.10.1` [TOC] :::info By @hwwhww 20200115 Special thanks to @djrtwo for the review. ::: :::warning Changelog * 20200212: Fix `PERSISTENT_COMMITTEE_PERIOD` value mistake. Thanks to Joseph Chow for finding out this mistake. * 20200127: Update to v0.10.1 - [fix exit queue](https://github.com/ethereum/eth2.0-specs/pull/1581) ::: # 1. Introduction The validator status is defined in the [beacon chain spec](https://github.com/ethereum/eth2.0-specs/blob/v0.10.0/specs/phase0/beacon-chain.md) with "beacon state transition" functions. This document describes the concept of validator status epochs and the cases of validator lifecycle in the view of "validator status transition" in phase 0. We also recommend you to read [Serenity Design Rationale - The validator lifecycle](https://notes.ethereum.org/@vbuterin/rkhCgQteN#The-validator-lifecycle) to understand the deep meaning of some constants configuration. # 2. Validator status ## 2.1. Statuses in phase 0 The validator may be in the following statuses: 1. **Deposited**: the validator has made a deposit and has registered in `BeaconState`. 2. **Eligible to be activated (Pending)**: the validator is eligible to be activated. 3. **Activated**: the validator is activated :::info Note that the validator may be "eligible to be activated, but has not been activated yet". ::: 4. **Slashed**: the validator has been slashed 5. **Exited**: the validator is exited 6. **Withdrawable**: the validator is withdrawable :::info Note that the validator will be able to withdraw to EEs in phase 2 ::: Note that in some cases, a validator can be in multiple statuses at the same time, e.g., an active validator may be "activated and slashed". ## 2.2. Validator status epoch To determine the status of validator, we maintain the *status epoch* fields for each validator in `BeaconState`. The fields include activation eligibility, activation, exit, and withdrawable. ![](https://storage.googleapis.com/ethereum-hackmd/upload_eca5ac48a840054374280d7c0ffbd556.png) These fields define that a validator is in $status_x$ status when $v.status\_epoch_x \geq current\_status$. The default value of the status epoch fields is $FAR\_FUTURE\_EPOCH$, where $FAR\_FUTURE\_EPOCH := 2^{64} - 1$ epochs. For example, if a validator $v_1$, where $v_1.activation\_eligibility\_epoch$ is $100$ and $v_1.activation\_epoch$ is $200$. - When current epoch is $150$, the validator is "eligibile" to be activated, but has not been *activated* yet. ![](https://storage.googleapis.com/ethereum-hackmd/upload_4ce9f0a6553c0974b0f9d54c3db7e386.png) - When current epoch is $250$, the validator is activated. ![](https://storage.googleapis.com/ethereum-hackmd/upload_d77aae8a701f1d89d5f2ab8786709639.png) \ By updating these fields, we can determine the validator statuses. Basically, the status epoch setting should follow: $$ activation\_eligibility\_epoch \leq acitivation\_epoch \leq exit\_epoch \leq withdrawable\_epoch \\ $$ ## 2.3. `validator.slashed` boolean flag We use a `slashed` flag field in `Validator` to describe if the validator has been slashed. ![](https://storage.googleapis.com/ethereum-hackmd/upload_4c1db5447b54f929c2fa6e5364e3bc22.png) You can find more information on slashing from the [validator guide doc](https://github.com/ethereum/eth2.0-specs/blob/v0.10.0/specs/phase0/validator.md). Note that a slashed validator will be forced to exit (we will discuss the details in Chapter 4). # 3. Rate-limiting activation/exits queues To (i) ensure the validator set is stable enough between two points and (ii) ensure that finality guarantees still remain between two chains as long as a validator logs on often enough ([weak subjectivity](https://ethresear.ch/t/weak-subjectivity-under-the-exit-queue-model/5187)), we limit the activation/exit queues dynamically. :::info Some rationale is described in [Serenity Design Rationale - Exiting](https://notes.ethereum.org/@vbuterin/rkhCgQteN?type=view#Exiting). ::: ## 3.1. Churn limit function The churn limit computation algorithm is describe in [get_validator_churn_limit](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#get_validator_churn_limit). $$ \begin{split} |S| &:= \text{the size of set } S \\ V_{active} &:= \text{the active validators} \\ churn\_limit(state) &:= max(MIN\_PER\_EPOCH\_CHURN\_LIMIT,\ \Big\lfloor{\frac{|V_{active}|}{CHURN\_LIMIT\_QUOTIENT}}\Big\rfloor ) \end{split} $$ For example, if the `churn_limit(state)` is $10$, that means at the current epoch, only the first $10$ validators in the activation queue could be initiated activation. In normal operation with sufficient validators, `CHURN_LIMIT_QUOTIENT` dictates the maximum fraction of validators that can churn in a given epoch. To ensure that validators can always activate/exit even when a low total validator count, `MIN_PER_EPOCH_CHURN_LIMIT` is in place. # 4. Validator lifecycle This section, we will explain each validator status transition step-by-step. The following is the state transition diagram: [![Diagram](https://storage.googleapis.com/ethereum-hackmd/upload_f76a1c2499efcaabcf2aa167986a06d3.png)](https://storage.googleapis.com/ethereum-hackmd/upload_f76a1c2499efcaabcf2aa167986a06d3.png) :::info 💡 Hint: click the image to see the full-size diagram. ::: ## 4.1. Step 1. Deposited The validator has deposited the deposit contract, and the corresponding `Deposit` operation has been processed. In epoch-processing, step $1.a$ checks if the validator [is eligible for activation queue](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue): - Check if 1. the validator has made enough deposit: $v.effective\_balance = MAX\_EFFECTIVE\_BALANCE$ 2. the validator's activation eligibility epoch has **not** been set (i.e. not previously added to the activition queue): $v.activation\_eligibility\_epoch = FAR\_FUTURE\_EPOCH$. - If yes, set $v.activation\_eligibility\_epoch$ to $current\_epoch + 1$ (thus entering the queue at the next epoch). - Else, go back to step $1.a$ at the next epoch. ## 4.2. Step 2. Eligible to be activated (Pending) In epoch-processing, step $2.a$ checks if the validator [is eligible for activation ](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#is_eligible_for_activation) and is **within churn limit**: - Select the activation queue -- the validators such that: 1. the validator's activation eligibility has been finalized: $v.activation\_eligibility\_epoch \leq state.finalized\_checkpoint.epoch$ 2. the validator’s activation epoch has **not** been set: $v.activation\_epoch = FAR\_FUTURE\_EPOCH$ - **Dequeue** validators for activation up to churn limit for the current epoch - If the validator gets dequeued, set $v.activation\_epoch$ to $current\_epoch + 1 + MAX\_SEED\_LOOKAHEAD$. - Else, go back to step $2.a$ at the next epoch. :::info Note that since we process epoch transition **right after** processing the last slot of epoch $n$. That's why we have to add $+1$ to the status epoch. ::: After $MAX\_SEED\_LOOKAHEAD$ epochs ($:=4$ epochs, **~25.6 minutes**), the validator will be [$3.\ Activated$](#43-Step-3-Activated). ## 4.3. Step 3. Activated The active validator will now be assigned duties each epoch (perform attesting, proposing, etc.) and gain rewards. Normally, we expect most validators will stay at the activated status for a long time. ### 4.3.1. Step 3.a Get slashed If a validator misbehaves (i.e., double voting or surround voting), the other validator can create a slashing operation to catch it on-chain, and the misbehaved validator will get *slashed*. Once the validator gets slashed when processing slashing operations, they will be forced to initiate exit, plus **extra ~36 days delay** before being *withdrawable*. #### 4.3.1.1. Initiate exit To [initiate exit](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#initiate_validator_exit), first, we check if the validator has **not** initiated exit before, i.e., $v.exit\_epoch = FAR\_FUTURE\_EPOCH$. If so, we compute the **exit queue epoch** (see below), and then set validator exit epoch and withdrawable epoch. Like the activation queue, The exit queue dequeue process is also based on the current churn rate: $$ \begin{split} exit\_epochs(state)\ &:= \{v.exit\_epoch\ \forall v\in V\ |\ v.exit\_epoch \not= FAR\_FUTURE\_EPOCH\big\} \\ exit\_queue\_epoch(state)\ &:= max\big\{exit\_epochs(state) \cup \{current\_epoch + 1 + MAX\_SEED\_LOOKAHEAD\}\big\} \\ v.exit\_epoch &:= exit\_queue\_epoch(state) \\ v.withdrawable\_epoch &:= v.exit\_epoch + MIN\_VALIDATOR\_WITHDRAWABILITY\_DELAY \end{split} $$ #### 4.3.1.2. Extra penal delay The slashed and exited validators suffer from a lock-in period of $2^{13}$ epochs (~36 days) before they become withdrawable. We have to delay withdrawalability by setting: $$ v.withdrawable\_epoch := max(v.withdrawable\_epoch, current\_epoch + EPOCHS\_PER\_SLASHINGS\_VECTOR) $$ :::info The reason why we set the penal delay twice is simply to reuse the helper function in spec. ::: :::success The validator's `exit_epoch` and `withdrawable_epoch` are set, which will trigger the status transitions for exit and withdrawable. ::: ### 4.3.2. Step 3.b Insufficient balance (ejection) If a validator gets [*penalized*](https://notes.ethereum.org/@djrtwo/Bkn3zpwxB?type=view#Rewards-and-Penalties), they lose portions of their balance. If the balance is too low, i.e., $v.effective\_balance \leq EJECTION\_BALANCE$, this validator is forcefully exited. #### 4.3.2.1. Initiate exit As same as [4.3.1.1. Initiate exit](#4311-Initiate-exit). :::success The validator's `exit_epoch` and `withdrawable_epoch` are set, which will trigger the status transitions for exit and withdrawable. ::: ### 4.3.3. Step 3.c Voluntary exit path The validator can [initiate exit voluntarily](https://notes.ethereum.org/@djrtwo/Bkn3zpwxB?type=view#Voluntary-Exits) by sending `VoluntaryExit` operation. #### 4.3.3.1. Minimum service time For added validator set stability, the validator can only initiate exit if $v.activation\_epoch + PERSISTENT\_COMMITTEE\_PERIOD \geq current\_state$, i.e., $2^{11}$ epochs (**~9 days**) after activation. #### 4.3.3.2. Initiate exit As same as [4.3.1.1. Initiate exit](#4311-Initiate-exit). :::success The validator's `exit_epoch` and `withdrawable_epoch` are set, which will trigger the status transitions for exit and withdrawable. ::: ## 4.4. Step 4. Slashed and Exited The slashed and exited validators will suffer from a long lock-in period of $2^{13}$ epochs (~36 days) before they become [$6.\ \text{Withdrawable}$](#46-Step-6-Withdrawable). ## 4.5. Step 5. Unslashed and Exited The unslashed and exited validators need to wait for $2^8$ epochs (**~27 hours**) to become [$6.\ \text{Withdrawable}$](#46-Step-6-Withdrawable). :::info This 27-hour waiting time is for: 1. Ensuring that if a validator misbehaved, there is a period of time within which the error can be caught, and the validator **can be slashed** even if the exit queue is nearly empty. If so, their withdrawalability will be delayed as [4.3.1.2. Extra penal delay](#4312-Extra-penal-delay). 2. Providing time for the last period of shard **rewards** to be included in phase 1. 3. Providing time for **proof of custody challenges** to be made in phase 1. ::: ## 4.6. Step 6. Withdrawable The withdrawable status is the end status in phase 0. Validators will be able to perform withdrawal in phase 2.

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lost their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.


Upgrade

All
  • All
  • Team
No template.

Create a template


Upgrade

Delete template

Do you really want to delete this template?

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Sign in via SAML

or

Sign in via GitHub

Help

  • English
  • 中文
  • 日本語

Documents

Tutorials

Book Mode Tutorial

Slide Example

YAML Metadata

Resources

Releases

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions

Versions and GitHub Sync

Sign in to link this note to GitHub Learn more
This note is not linked with GitHub Learn more
 
Add badge Pull Push GitHub Link Settings
Upgrade now

Version named by    

More Less
  • Edit
  • Delete

Note content is identical to the latest version.
Compare with
    Choose a version
    No search result
    Version not found

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub

      Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

       Sign in to GitHub

      HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully