84 lines
3.0 KiB
Markdown
Raw Normal View History

2023-09-14 13:44:32 +02:00
EIP-7514 -- The Beacon Chain
2023-09-12 10:33:36 +02:00
## Table of contents
<!-- TOC -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [Introduction](#introduction)
- [Configuration](#configuration)
- [Validator cycle](#validator-cycle)
- [Helper functions](#helper-functions)
- [Beacon state accessors](#beacon-state-accessors)
2023-09-13 10:57:52 +02:00
- [New `get_validator_activation_churn_limit`](#new-get_validator_activation_churn_limit)
2023-09-12 10:33:36 +02:00
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
- [Epoch processing](#epoch-processing)
- [Registry updates](#registry-updates)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- /TOC -->
## Introduction
This is the beacon chain specification to limit the max inbound churn value, motivated to limit the validator active set growth rate.
*Note:* This specification is built upon [Capella](../../capella/beacon_chain.md) and is under active development.
## Configuration
### Validator cycle
| Name | Value |
| - | - |
2023-09-14 16:31:42 +02:00
| `MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT` | `uint64(8)` (= 8) |
2023-09-12 10:33:36 +02:00
## Helper functions
### Beacon state accessors
2023-09-13 10:57:52 +02:00
#### New `get_validator_activation_churn_limit`
2023-09-12 10:33:36 +02:00
```python
2023-09-13 10:57:52 +02:00
def get_validator_activation_churn_limit(state: BeaconState) -> uint64:
2023-09-12 10:33:36 +02:00
"""
2023-09-13 10:57:52 +02:00
Return the validator activation churn limit for the current epoch.
2023-09-12 10:33:36 +02:00
"""
2023-09-13 17:04:39 +08:00
return min(MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT, get_validator_churn_limit(state))
2023-09-12 10:33:36 +02:00
```
## Beacon chain state transition function
### Epoch processing
#### Registry updates
2023-09-14 13:44:32 +02:00
Note: The function `process_registry_updates` is modified to utilize `get_validator_inbound_churn_limit()` the rate limit the activation queue for EIP-7514.
2023-09-13 10:57:52 +02:00
2023-09-12 10:33:36 +02:00
```python
def process_registry_updates(state: BeaconState) -> None:
# Process activation eligibility and ejections
for index, validator in enumerate(state.validators):
if is_eligible_for_activation_queue(validator):
validator.activation_eligibility_epoch = get_current_epoch(state) + 1
if (
is_active_validator(validator, get_current_epoch(state))
and validator.effective_balance <= EJECTION_BALANCE
):
initiate_validator_exit(state, ValidatorIndex(index))
# Queue validators eligible for activation and not yet dequeued for activation
activation_queue = sorted([
index for index, validator in enumerate(state.validators)
if is_eligible_for_activation(state, validator)
# Order by the sequence of activation_eligibility_epoch setting and then index
], key=lambda index: (state.validators[index].activation_eligibility_epoch, index))
# Dequeued validators for activation up to churn limit
2023-09-14 13:44:32 +02:00
# [Modified in EIP7514]
2023-09-13 10:57:52 +02:00
for index in activation_queue[:get_validator_activation_churn_limit(state)]:
2023-09-12 10:33:36 +02:00
validator = state.validators[index]
validator.activation_epoch = compute_activation_exit_epoch(get_current_epoch(state))
```