From 2ca28fb86168848994055696e6c69dadf386ef32 Mon Sep 17 00:00:00 2001 From: tersec Date: Wed, 8 Dec 2021 17:29:22 +0000 Subject: [PATCH] Merge BeaconBlock gossip validation (#3165) * Merge BeaconBlock gossip validation * figure/ground inversion * revert cosmetic cleanups to reduce merge conflicts --- .../block_pools_types.nim | 4 ++ .../consensus_object_pools/blockchain_dag.nim | 10 ++- beacon_chain/eth1/eth1_monitor.nim | 2 +- .../gossip_processing/eth2_processor.nim | 5 +- .../gossip_processing/gossip_validation.nim | 62 +++++++++++++++++-- beacon_chain/nimbus_beacon_node.nim | 5 ++ 6 files changed, 78 insertions(+), 10 deletions(-) diff --git a/beacon_chain/consensus_object_pools/block_pools_types.nim b/beacon_chain/consensus_object_pools/block_pools_types.nim index d6cedd66b..25063326c 100644 --- a/beacon_chain/consensus_object_pools/block_pools_types.nim +++ b/beacon_chain/consensus_object_pools/block_pools_types.nim @@ -177,6 +177,10 @@ type eth1_deposit_index*: uint64 beacon_proposers*: array[SLOTS_PER_EPOCH, Option[ValidatorIndex]] shuffled_active_validator_indices*: seq[ValidatorIndex] + + # enables more efficient merge block validation + merge_transition_complete*: bool + # balances, as used in fork choice effective_balances_bytes*: seq[byte] diff --git a/beacon_chain/consensus_object_pools/blockchain_dag.nim b/beacon_chain/consensus_object_pools/blockchain_dag.nim index 2539bdbd8..4e586e384 100644 --- a/beacon_chain/consensus_object_pools/blockchain_dag.nim +++ b/beacon_chain/consensus_object_pools/blockchain_dag.nim @@ -153,7 +153,15 @@ func init*( getStateField(state.data, current_justified_checkpoint), finalized_checkpoint: getStateField(state.data, finalized_checkpoint), shuffled_active_validator_indices: - cache.get_shuffled_active_validator_indices(state.data, epoch) + cache.get_shuffled_active_validator_indices(state.data, epoch), + merge_transition_complete: + case state.data.kind: + of BeaconStateFork.Phase0: false + of BeaconStateFork.Altair: false + of BeaconStateFork.Merge: + # https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/beacon-chain.md#is_merge_transition_complete + state.data.mergeData.data.latest_execution_payload_header != + ExecutionPayloadHeader() ) for i in 0'u64..