From 840733ffd2994d2ef361175fe98b9cff4e7403e5 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Thu, 23 Jun 2022 20:55:18 +0200 Subject: [PATCH] Move `compute_fork_version` to `fork.md` --- specs/altair/beacon-chain.md | 13 ------------- specs/altair/fork.md | 19 +++++++++++++++++++ specs/bellatrix/beacon-chain.md | 15 --------------- specs/bellatrix/fork.md | 21 +++++++++++++++++++++ specs/capella/beacon-chain.md | 20 -------------------- specs/capella/fork.md | 23 +++++++++++++++++++++++ 6 files changed, 63 insertions(+), 48 deletions(-) diff --git a/specs/altair/beacon-chain.md b/specs/altair/beacon-chain.md index fadce93ef..a14ddb4f6 100644 --- a/specs/altair/beacon-chain.md +++ b/specs/altair/beacon-chain.md @@ -28,7 +28,6 @@ - [Helper functions](#helper-functions) - [Crypto](#crypto) - [Misc](#misc-1) - - [`compute_fork_version`](#compute_fork_version) - [`add_flag`](#add_flag) - [`has_flag`](#has_flag) - [Beacon state accessors](#beacon-state-accessors) @@ -227,18 +226,6 @@ the functionality described in those documents. ### Misc -#### `compute_fork_version` - -```python -def compute_fork_version(epoch: Epoch) -> Version: - """ - Return the fork version at the given ``epoch``. - """ - if epoch >= ALTAIR_FORK_EPOCH: - return ALTAIR_FORK_VERSION - return GENESIS_FORK_VERSION -``` - #### `add_flag` ```python diff --git a/specs/altair/fork.md b/specs/altair/fork.md index 6228022b8..bf8499a21 100644 --- a/specs/altair/fork.md +++ b/specs/altair/fork.md @@ -7,6 +7,9 @@ - [Introduction](#introduction) - [Configuration](#configuration) +- [Helper functions](#helper-functions) + - [Misc](#misc) + - [`compute_fork_version`](#compute_fork_version) - [Fork to Altair](#fork-to-altair) - [Fork trigger](#fork-trigger) - [Upgrading the state](#upgrading-the-state) @@ -26,6 +29,22 @@ Warning: this configuration is not definitive. | `ALTAIR_FORK_VERSION` | `Version('0x01000000')` | | `ALTAIR_FORK_EPOCH` | `Epoch(74240)` (Oct 27, 2021, 10:56:23am UTC) | +## Helper functions + +### Misc + +#### `compute_fork_version` + +```python +def compute_fork_version(epoch: Epoch) -> Version: + """ + Return the fork version at the given ``epoch``. + """ + if epoch >= ALTAIR_FORK_EPOCH: + return ALTAIR_FORK_VERSION + return GENESIS_FORK_VERSION +``` + ## Fork to Altair ### Fork trigger diff --git a/specs/bellatrix/beacon-chain.md b/specs/bellatrix/beacon-chain.md index f92c4cbf5..b37a8ab71 100644 --- a/specs/bellatrix/beacon-chain.md +++ b/specs/bellatrix/beacon-chain.md @@ -29,7 +29,6 @@ - [`is_execution_enabled`](#is_execution_enabled) - [Misc](#misc) - [`compute_timestamp_at_slot`](#compute_timestamp_at_slot) - - [Modified `compute_fork_version`](#modified-compute_fork_version) - [Beacon state accessors](#beacon-state-accessors) - [Modified `get_inactivity_penalty_deltas`](#modified-get_inactivity_penalty_deltas) - [Beacon state mutators](#beacon-state-mutators) @@ -243,20 +242,6 @@ def compute_timestamp_at_slot(state: BeaconState, slot: Slot) -> uint64: return uint64(state.genesis_time + slots_since_genesis * SECONDS_PER_SLOT) ``` -#### Modified `compute_fork_version` - -```python -def compute_fork_version(epoch: Epoch) -> Version: - """ - Return the fork version at the given ``epoch``. - """ - if epoch >= BELLATRIX_FORK_EPOCH: - return BELLATRIX_FORK_VERSION - if epoch >= ALTAIR_FORK_EPOCH: - return ALTAIR_FORK_VERSION - return GENESIS_FORK_VERSION -``` - ### Beacon state accessors #### Modified `get_inactivity_penalty_deltas` diff --git a/specs/bellatrix/fork.md b/specs/bellatrix/fork.md index 8cb34099b..5c0e174da 100644 --- a/specs/bellatrix/fork.md +++ b/specs/bellatrix/fork.md @@ -9,6 +9,9 @@ - [Introduction](#introduction) - [Configuration](#configuration) +- [Helper functions](#helper-functions) + - [Misc](#misc) + - [Modified `compute_fork_version`](#modified-compute_fork_version) - [Fork to Bellatrix](#fork-to-bellatrix) - [Fork trigger](#fork-trigger) - [Upgrading the state](#upgrading-the-state) @@ -28,6 +31,24 @@ Warning: this configuration is not definitive. | `BELLATRIX_FORK_VERSION` | `Version('0x02000000')` | | `BELLATRIX_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** | +## Helper functions + +### Misc + +#### Modified `compute_fork_version` + +```python +def compute_fork_version(epoch: Epoch) -> Version: + """ + Return the fork version at the given ``epoch``. + """ + if epoch >= BELLATRIX_FORK_EPOCH: + return BELLATRIX_FORK_VERSION + if epoch >= ALTAIR_FORK_EPOCH: + return ALTAIR_FORK_VERSION + return GENESIS_FORK_VERSION +``` + ## Fork to Bellatrix ### Fork trigger diff --git a/specs/capella/beacon-chain.md b/specs/capella/beacon-chain.md index e2b47dd1f..da67a8fcb 100644 --- a/specs/capella/beacon-chain.md +++ b/specs/capella/beacon-chain.md @@ -34,8 +34,6 @@ - [`has_eth1_withdrawal_credential`](#has_eth1_withdrawal_credential) - [`is_fully_withdrawable_validator`](#is_fully_withdrawable_validator) - [`is_partially_withdrawable_validator`](#is_partially_withdrawable_validator) - - [Misc](#misc-1) - - [Modified `compute_fork_version`](#modified-compute_fork_version) - [Beacon chain state transition function](#beacon-chain-state-transition-function) - [Epoch processing](#epoch-processing) - [Full withdrawals](#full-withdrawals) @@ -320,24 +318,6 @@ def is_partially_withdrawable_validator(validator: Validator, balance: Gwei) -> return has_eth1_withdrawal_credential(validator) and has_max_effective_balance and has_excess_balance ``` -### Misc - -#### Modified `compute_fork_version` - -```python -def compute_fork_version(epoch: Epoch) -> Version: - """ - Return the fork version at the given ``epoch``. - """ - if epoch >= CAPELLA_FORK_EPOCH: - return CAPELLA_FORK_VERSION - if epoch >= BELLATRIX_FORK_EPOCH: - return BELLATRIX_FORK_VERSION - if epoch >= ALTAIR_FORK_EPOCH: - return ALTAIR_FORK_VERSION - return GENESIS_FORK_VERSION -``` - ## Beacon chain state transition function ### Epoch processing diff --git a/specs/capella/fork.md b/specs/capella/fork.md index 0d8283e56..c22387ee7 100644 --- a/specs/capella/fork.md +++ b/specs/capella/fork.md @@ -7,6 +7,9 @@ - [Introduction](#introduction) - [Configuration](#configuration) +- [Helper functions](#helper-functions) + - [Misc](#misc) + - [Modified `compute_fork_version`](#modified-compute_fork_version) - [Fork to Capella](#fork-to-capella) - [Fork trigger](#fork-trigger) - [Upgrading the state](#upgrading-the-state) @@ -27,6 +30,26 @@ Warning: this configuration is not definitive. | `CAPELLA_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** | +## Helper functions + +### Misc + +#### Modified `compute_fork_version` + +```python +def compute_fork_version(epoch: Epoch) -> Version: + """ + Return the fork version at the given ``epoch``. + """ + if epoch >= CAPELLA_FORK_EPOCH: + return CAPELLA_FORK_VERSION + if epoch >= BELLATRIX_FORK_EPOCH: + return BELLATRIX_FORK_VERSION + if epoch >= ALTAIR_FORK_EPOCH: + return ALTAIR_FORK_VERSION + return GENESIS_FORK_VERSION +``` + ## Fork to Capella ### Fork trigger