From d95a905b2b5f8d8ce7609d5744cd8f63852e4ebb Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Thu, 6 Oct 2022 18:25:24 +0100 Subject: [PATCH] Fix Re-Org Back into Canonical Chain hive test (#5647) Co-authored-by: Alexey Sharp --- ethdb/privateapi/ethbackend.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ethdb/privateapi/ethbackend.go b/ethdb/privateapi/ethbackend.go index 738477d37..678885eea 100644 --- a/ethdb/privateapi/ethbackend.go +++ b/ethdb/privateapi/ethbackend.go @@ -470,6 +470,18 @@ func (s *EthBackendServer) getQuickPayloadStatusIfPossible(blockHash common.Hash log.Debug(fmt.Sprintf("[%s] Downloading some other PoS stuff", prefix), "hash", blockHash) return &engineapi.PayloadStatus{Status: remote.EngineStatus_SYNCING}, nil } + // Following code ensures we skip the fork choice state update if if forkchoiceState.headBlockHash references an ancestor of the head of canonical chain + headHash := rawdb.ReadHeadBlockHash(tx) + if err != nil { + return nil, err + } + + // We add the extra restriction blockHash != headHash for the FCU case of canonicalHash == blockHash + // because otherwise (when FCU points to the head) we want go to stage headers + // so that it calls writeForkChoiceHashes. + if blockHash != headHash && canonicalHash == blockHash { + return &engineapi.PayloadStatus{Status: remote.EngineStatus_VALID, LatestValidHash: blockHash}, nil + } } // If another payload is already commissioned then we just reply with syncing