fix finalization bug

This commit is contained in:
Danny Ryan 2019-04-17 08:57:23 -06:00
parent 0fd42a7815
commit 4bffa87646
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
1 changed files with 2 additions and 2 deletions

View File

@ -1711,11 +1711,11 @@ def update_justification_and_finalization(state: BeaconState) -> None:
state.finalized_epoch = antepenultimate_justified_epoch state.finalized_epoch = antepenultimate_justified_epoch
state.finalized_root = get_block_root(state, get_epoch_start_slot(state.finalized_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 # 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_root == current_epoch - 2: if (bitfield >> 0) % 8 == 0b111 and state.previous_justified_epoch == current_epoch - 2:
state.finalized_epoch = state.previous_justified_root state.finalized_epoch = state.previous_justified_root
state.finalized_root = get_block_root(state, get_epoch_start_slot(state.finalized_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 # The 1st/2nd most recent epochs are justified, the 1st using the 2nd as source
if (bitfield >> 0) % 4 == 0b11 and state.previous_justified_root == current_epoch - 1: if (bitfield >> 0) % 4 == 0b11 and state.previous_justified_epoch == current_epoch - 1:
state.finalized_epoch = state.previous_justified_root state.finalized_epoch = state.previous_justified_root
state.finalized_root = get_block_root(state, get_epoch_start_slot(state.finalized_epoch)) state.finalized_root = get_block_root(state, get_epoch_start_slot(state.finalized_epoch))
``` ```