From b7f3d37a528b8b8e3c2ce250eded3855d0b04552 Mon Sep 17 00:00:00 2001 From: Ben Edgington Date: Fri, 21 Apr 2023 09:16:51 +0100 Subject: [PATCH] Move is_previous_epoch_justified --- specs/phase0/fork-choice.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/specs/phase0/fork-choice.md b/specs/phase0/fork-choice.md index 6e281d5c3d..f39a9234c0 100644 --- a/specs/phase0/fork-choice.md +++ b/specs/phase0/fork-choice.md @@ -11,8 +11,8 @@ - [Configuration](#configuration) - [Helpers](#helpers) - [`LatestMessage`](#latestmessage) - - [`is_previous_epoch_justified`](#is_previous_epoch_justified) - [`Store`](#store) + - [`is_previous_epoch_justified`](#is_previous_epoch_justified) - [`get_forkchoice_store`](#get_forkchoice_store) - [`get_slots_since_genesis`](#get_slots_since_genesis) - [`get_current_slot`](#get_current_slot) @@ -92,17 +92,6 @@ class LatestMessage(object): root: Root ``` - -### `is_previous_epoch_justified` - -```python -def is_previous_epoch_justified(store: Store) -> bool: - current_slot = get_current_slot(store) - current_epoch = compute_epoch_at_slot(current_slot) - return store.justified_checkpoint.epoch + 1 == current_epoch -``` - - #### `Store` The `Store` is responsible for tracking information required for the fork choice algorithm. The important fields being tracked are described below: @@ -130,6 +119,15 @@ class Store(object): unrealized_justifications: Dict[Root, Checkpoint] = field(default_factory=dict) ``` +#### `is_previous_epoch_justified` + +```python +def is_previous_epoch_justified(store: Store) -> bool: + current_slot = get_current_slot(store) + current_epoch = compute_epoch_at_slot(current_slot) + return store.justified_checkpoint.epoch + 1 == current_epoch +``` + #### `get_forkchoice_store` The provided anchor-state will be regarded as a trusted state, to not roll back beyond.