Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move is_previous_epoch_justified #3337

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions specs/phase0/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down