From 3f384cc4553466d80f75461532426cae7e658f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 1 Dec 2023 12:04:18 -0300 Subject: [PATCH] fix: `get_head` not propagating `blocks` updates (#493) --- .../fork_choice/helpers.ex | 11 ++++++----- .../state_transition/state_transition.ex | 5 +---- lib/spec/runners/fork_choice.ex | 18 +++++++++--------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/lambda_ethereum_consensus/fork_choice/helpers.ex b/lib/lambda_ethereum_consensus/fork_choice/helpers.ex index 3a4baaa6b..ce38e83ee 100644 --- a/lib/lambda_ethereum_consensus/fork_choice/helpers.ex +++ b/lib/lambda_ethereum_consensus/fork_choice/helpers.ex @@ -123,14 +123,15 @@ defmodule LambdaEthereumConsensus.ForkChoice.Helpers do # If any children branches contain expected finalized/justified checkpoints, # add to filtered block-tree and signal viability to parent. - filter_block_tree_result = Enum.map(children, &filter_block_tree(store, &1, blocks)) + {filter_block_tree_result, new_blocks} = + Enum.map_reduce(children, blocks, fn root, acc -> filter_block_tree(store, root, acc) end) cond do - Enum.any?(filter_block_tree_result, fn {b, _} -> b end) -> - {true, Map.put(blocks, block_root, block)} + Enum.any?(filter_block_tree_result) -> + {true, Map.put(new_blocks, block_root, block)} - Enum.any?(children) -> - {false, blocks} + not Enum.empty?(children) -> + {false, new_blocks} true -> filter_leaf_block(store, block_root, block, blocks) diff --git a/lib/lambda_ethereum_consensus/state_transition/state_transition.ex b/lib/lambda_ethereum_consensus/state_transition/state_transition.ex index cd190b952..0a0778d5b 100644 --- a/lib/lambda_ethereum_consensus/state_transition/state_transition.ex +++ b/lib/lambda_ethereum_consensus/state_transition/state_transition.ex @@ -15,11 +15,8 @@ defmodule LambdaEthereumConsensus.StateTransition do def state_transition( %BeaconState{} = state, %SignedBeaconBlock{message: block} = signed_block, - _validate_result + validate_result ) do - # NOTE: we aren't in a state to make validations yet - validate_result = false - state # Process slots (including those with no blocks) since block |> process_slots(block.slot) diff --git a/lib/spec/runners/fork_choice.ex b/lib/spec/runners/fork_choice.ex index 49e4b9aa9..0e6044987 100644 --- a/lib/spec/runners/fork_choice.ex +++ b/lib/spec/runners/fork_choice.ex @@ -11,7 +11,7 @@ defmodule ForkChoiceTestRunner do alias SszTypes.Store @disabled_on_block_cases [ - "basic", + # "basic", "incompatible_justification_update_end_of_epoch", "incompatible_justification_update_start_of_epoch", "justification_update_beginning_of_epoch", @@ -23,28 +23,28 @@ defmodule ForkChoiceTestRunner do "justified_update_not_realized_finality", "new_finalized_slot_is_justified_checkpoint_ancestor", "not_pull_up_current_epoch_block", - "on_block_bad_parent_root", + # "on_block_bad_parent_root", "on_block_before_finalized", "on_block_checkpoints", "on_block_finalized_skip_slots", "on_block_finalized_skip_slots_not_in_skip_chain", - "on_block_future_block", - "proposer_boost", - "proposer_boost_root_same_slot_untimely_block", + # "on_block_future_block", + # "proposer_boost", + # "proposer_boost_root_same_slot_untimely_block", "pull_up_on_tick", "pull_up_past_epoch_block" ] @disabled_ex_ante_cases [ - "ex_ante_attestations_is_greater_than_proposer_boost_with_boost", + # "ex_ante_attestations_is_greater_than_proposer_boost_with_boost", "ex_ante_sandwich_with_boost_not_sufficient", "ex_ante_sandwich_with_honest_attestation", - "ex_ante_sandwich_without_attestations", - "ex_ante_vanilla" + "ex_ante_sandwich_without_attestations" + # "ex_ante_vanilla" ] @disabled_get_head_cases [ - "chain_no_attestations", + # "chain_no_attestations", "discard_equivocations_on_attester_slashing", "discard_equivocations_slashed_validator_censoring", "filtered_block_tree",