From 377c7d799ff62c6060939a4f95532df93a345f63 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 28 Jul 2022 15:16:15 +0200 Subject: [PATCH] eth/catalyst: return 0x0 if latestvalid is pow block (#25423) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * eth/catalyst: return 0x0 if latestvalid is pow block * eth/catalyst: return 0x0 if latestvalid is pow block * eth/catalyst: fix header retrieval, fix sign check Co-authored-by: Péter Szilágyi --- eth/catalyst/api.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 6287bdab4..c5f2313ca 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -479,10 +479,15 @@ func (api *ConsensusAPI) checkInvalidAncestor(check common.Hash, head common.Has } api.invalidTipsets[head] = invalid } + // If the last valid hash is the terminal pow block, return 0x0 for latest valid hash + lastValid := &invalid.ParentHash + if header := api.eth.BlockChain().GetHeader(invalid.ParentHash, invalid.Number.Uint64()-1); header != nil && header.Difficulty.Sign() != 0 { + lastValid = &common.Hash{} + } failure := "links to previously rejected block" return &beacon.PayloadStatusV1{ Status: beacon.INVALID, - LatestValidHash: &invalid.ParentHash, + LatestValidHash: lastValid, ValidationError: &failure, } }