Skip to content

Commit

Permalink
Merge pull request #3337 from benjaminion/move-is-prev-epoch-just
Browse files Browse the repository at this point in the history
Move is_previous_epoch_justified
  • Loading branch information
hwwhww committed Apr 21, 2023
2 parents 3c8114c + b7f3d37 commit 1a38b83
Showing 1 changed file with 10 additions and 12 deletions.
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

0 comments on commit 1a38b83

Please sign in to comment.