mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-03 14:24:24 +00:00
Further decouple justification and finalisation (#958)
Addresses @djrtwo's comment [here](https://github.com/ethereum/eth2.0-specs/pull/925#issuecomment-484123950).
This commit is contained in:
parent
e2e39d63a5
commit
443786017f
@ -1683,7 +1683,8 @@ def update_justification_and_finalization(state: BeaconState) -> None:
|
||||
if get_current_epoch(state) <= GENESIS_EPOCH + 1:
|
||||
return
|
||||
|
||||
antepenultimate_justified_epoch = state.previous_justified_epoch
|
||||
old_previous_justified_epoch = state.previous_justified_epoch
|
||||
old_current_justified_epoch = state.current_justified_epoch
|
||||
|
||||
# Process justifications
|
||||
state.previous_justified_epoch = state.current_justified_epoch
|
||||
@ -1704,20 +1705,20 @@ def update_justification_and_finalization(state: BeaconState) -> None:
|
||||
bitfield = state.justification_bitfield
|
||||
current_epoch = get_current_epoch(state)
|
||||
# The 2nd/3rd/4th most recent epochs are justified, the 2nd using the 4th as source
|
||||
if (bitfield >> 1) % 8 == 0b111 and antepenultimate_justified_epoch == current_epoch - 3:
|
||||
state.finalized_epoch = antepenultimate_justified_epoch
|
||||
if (bitfield >> 1) % 8 == 0b111 and old_previous_justified_epoch == current_epoch - 3:
|
||||
state.finalized_epoch = old_previous_justified_epoch
|
||||
state.finalized_root = get_block_root(state, get_epoch_start_slot(state.finalized_epoch))
|
||||
# The 2nd/3rd most recent epochs are justified, the 2nd using the 3rd as source
|
||||
if (bitfield >> 1) % 4 == 0b11 and antepenultimate_justified_epoch == current_epoch - 2:
|
||||
state.finalized_epoch = antepenultimate_justified_epoch
|
||||
if (bitfield >> 1) % 4 == 0b11 and old_previous_justified_epoch == current_epoch - 2:
|
||||
state.finalized_epoch = old_previous_justified_epoch
|
||||
state.finalized_root = get_block_root(state, get_epoch_start_slot(state.finalized_epoch))
|
||||
# The 1st/2nd/3rd most recent epochs are justified, the 1st using the 3rd as source
|
||||
if (bitfield >> 0) % 8 == 0b111 and state.previous_justified_epoch == current_epoch - 2:
|
||||
state.finalized_epoch = state.previous_justified_epoch
|
||||
if (bitfield >> 0) % 8 == 0b111 and old_current_justified_epoch == current_epoch - 2:
|
||||
state.finalized_epoch = old_current_justified_epoch
|
||||
state.finalized_root = get_block_root(state, get_epoch_start_slot(state.finalized_epoch))
|
||||
# The 1st/2nd most recent epochs are justified, the 1st using the 2nd as source
|
||||
if (bitfield >> 0) % 4 == 0b11 and state.previous_justified_epoch == current_epoch - 1:
|
||||
state.finalized_epoch = state.previous_justified_epoch
|
||||
if (bitfield >> 0) % 4 == 0b11 and old_current_justified_epoch == current_epoch - 1:
|
||||
state.finalized_epoch = old_current_justified_epoch
|
||||
state.finalized_root = get_block_root(state, get_epoch_start_slot(state.finalized_epoch))
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user