Fix `parent_state_advanced` side effect and reorder the conditions

This commit is contained in:
Hsiao-Wei Wang 2023-10-25 01:34:57 +08:00
parent 24b4d46903
commit 22215b8fe4
No known key found for this signature in database
GPG Key ID: AE3D6B174F971DE4
1 changed files with 7 additions and 6 deletions

View File

@ -110,15 +110,15 @@ def should_override_forkchoice_update(store: Store, head_root: Root) -> bool:
# FFG information of the new head_block will be competitive with the current head.
ffg_competitive = is_ffg_competitive(store, head_root, parent_root)
# Do not re-org if the chain is not finalizing with acceptable frequency.
finalization_ok = is_finalization_ok(store, proposal_slot)
# Only suppress the fork choice update if we are confident that we will propose the next block.
parent_state_advanced = store.block_states[parent_root]
parent_state_advanced = store.block_states[parent_root].copy()
process_slots(parent_state_advanced, proposal_slot)
proposer_index = get_beacon_proposer_index(parent_state_advanced)
proposing_reorg_slot = validator_is_connected(proposer_index)
# Do not re-org if the chain is not finalizing with acceptable frequency.
finalization_ok = is_finalization_ok(store, proposal_slot)
# Single slot re-org.
parent_slot_ok = parent_block.slot + 1 == head_block.slot
proposing_on_time = is_proposing_on_time(store)
@ -138,8 +138,9 @@ def should_override_forkchoice_update(store: Store, head_root: Root) -> bool:
head_weak = True
parent_strong = True
return all([head_late, shuffling_stable, proposing_reorg_slot, ffg_competitive, finalization_ok,
single_slot_reorg, head_weak, parent_strong])
return all([head_late, shuffling_stable, ffg_competitive, finalization_ok,
proposing_reorg_slot, single_slot_reorg,
head_weak, parent_strong])
```
*Note*: The ordering of conditions is a suggestion only. Implementations are free to