From c7e4e89a5fc6d868c79a7f5fb98083b5fbd346cb Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 10 Feb 2025 18:50:27 +0100 Subject: [PATCH] consensus/beacon: clarify isPreMerge --- consensus/beacon/consensus.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 56f4937eda..7d34466628 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -72,9 +72,12 @@ func New(ethone consensus.Engine) *Beacon { return &Beacon{ethone: ethone} } +// isPreMerge reports whether the given block number is assumed to be pre-merge. +// Here we check the MergeNetsplitBlock to allow configuring networks with a PoW or +// PoA chain for unit testing purposes. func isPreMerge(config *params.ChainConfig, block uint64) bool { - return !(config.TerminalTotalDifficulty != nil && config.TerminalTotalDifficulty.Sign() == 0) || - (config.MergeNetsplitBlock != nil && block < config.MergeNetsplitBlock.Uint64()) + mergedAtGenesis := config.TerminalTotalDifficulty != nil && config.TerminalTotalDifficulty.Sign() == 0 + return !mergedAtGenesis && config.MergeNetsplitBlock != nil && block < config.MergeNetsplitBlock.Uint64() } // Author implements consensus.Engine, returning the verified author of the block.