From 815f19f7089f6fc8a6efa3396433b799b91d7a44 Mon Sep 17 00:00:00 2001 From: dapplion <35266934+dapplion@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:22:37 +0200 Subject: [PATCH] Add limit churn feature --- specs/_features/limit_churn/beacon_chain.md | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 specs/_features/limit_churn/beacon_chain.md diff --git a/specs/_features/limit_churn/beacon_chain.md b/specs/_features/limit_churn/beacon_chain.md new file mode 100644 index 0000000000..a2295f38e3 --- /dev/null +++ b/specs/_features/limit_churn/beacon_chain.md @@ -0,0 +1,52 @@ +Limit churn -- The Beacon Chain + +## Table of contents + + + + + +- [Introduction](#introduction) +- [Configuration](#configuration) + - [Validator cycle](#validator-cycle) +- [Helper functions](#helper-functions) + - [Beacon state accessors](#beacon-state-accessors) + - [modified `get_validator_churn_limit`](#modified-get_validator_churn_limit) + + + + +## Introduction + +This is the beacon chain specification to limit the max 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 | +| - | - | +| `MAX_PER_EPOCH_CHURN_LIMIT` | `uint64(12)` (= 12) | + +## Helper functions + +### Beacon state accessors + +#### modified `get_validator_churn_limit` + +```python +def get_validator_churn_limit(state: BeaconState) -> uint64: + """ + Return the validator churn limit for the current epoch. + """ + active_validator_indices = get_active_validator_indices(state, get_current_epoch(state)) + return min( + MAX_PER_EPOCH_CHURN_LIMIT, + max( + MIN_PER_EPOCH_CHURN_LIMIT, + uint64(len(active_validator_indices)) // CHURN_LIMIT_QUOTIENT + ) + ) +```