From 22215b8fe467d16ced6698e6d99c0204fb28165c Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Wed, 25 Oct 2023 01:34:57 +0800 Subject: [PATCH] Fix `parent_state_advanced` side effect and reorder the conditions --- specs/bellatrix/fork-choice.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/specs/bellatrix/fork-choice.md b/specs/bellatrix/fork-choice.md index fd70cfff4..d78862037 100644 --- a/specs/bellatrix/fork-choice.md +++ b/specs/bellatrix/fork-choice.md @@ -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