eth2.0-specs/specs/_features/eip6914/beacon-chain.md

66 lines
2.0 KiB
Markdown
Raw Normal View History

2023-04-19 23:47:49 +00:00
EIP-6914 -- The Beacon Chain
2023-03-28 03:03:14 +00: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)
- [Preset](#preset)
- [Time parameters](#time-parameters)
2023-04-04 03:00:09 +00:00
- [Helper functions](#helper-functions)
2023-03-28 06:34:07 +00:00
- [Predicates](#predicates)
- [`is_reusable_validator`](#is_reusable_validator)
2023-03-28 03:03:14 +00:00
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
- [Block processing](#block-processing)
2023-03-28 06:34:07 +00:00
- [Modified `get_index_for_new_validator`](#modified-get_index_for_new_validator)
2023-03-28 03:03:14 +00:00
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- /TOC -->
## Introduction
2023-04-19 23:47:49 +00:00
This is the beacon chain specification to assign new deposits to existing validator records. Refers to [EIP-6914](https://github.com/ethereum/EIPs/pull/6914).
2023-03-28 03:03:14 +00:00
*Note:* This specification is built upon [Capella](../../capella/beacon_chain.md) and is under active development.
## Preset
### Time parameters
| Name | Value | Unit | Duration |
2023-04-04 02:45:08 +00:00
| - | - | - | - |
2023-04-19 23:52:25 +00:00
| `SAFE_EPOCHS_TO_REUSE_INDEX` | `uint64(2**16)` (= 65,536) | epochs | ~0.8 year |
2023-03-28 03:03:14 +00:00
2023-03-28 06:34:07 +00:00
## Helper functions
### Predicates
#### `is_reusable_validator`
```python
def is_reusable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> bool:
"""
Check if ``validator`` index can be re-assigned to a new deposit.
"""
return (
2023-04-19 23:52:25 +00:00
epoch > validator.withdrawable_epoch + SAFE_EPOCHS_TO_REUSE_INDEX
and balance == 0
2023-03-28 06:34:07 +00:00
)
```
2023-03-28 03:03:14 +00:00
## Beacon chain state transition function
### Block processing
2023-03-28 06:34:07 +00:00
#### Modified `get_index_for_new_validator`
2023-03-28 03:03:14 +00:00
```python
2023-03-30 00:11:36 +00:00
def get_index_for_new_validator(state: BeaconState) -> ValidatorIndex:
2023-03-28 03:03:14 +00:00
for index, validator in enumerate(state.validators):
2023-03-28 06:34:07 +00:00
if is_reusable_validator(validator, state.balances[index], get_current_epoch(state)):
2023-03-30 00:11:36 +00:00
return ValidatorIndex(index)
return ValidatorIndex(len(state.validators))
2023-03-28 03:03:14 +00:00
```