From cfc9d5aaa92cd4a34afb2ac99ce07bfde62b152e Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Sat, 12 Mar 2022 13:54:07 +0200 Subject: [PATCH] Use nil suggestedLowHash if selected parent pruning point is not in the future of the current one --- .../processes/pruningmanager/pruningmanager.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/domain/consensus/processes/pruningmanager/pruningmanager.go b/domain/consensus/processes/pruningmanager/pruningmanager.go index 65cc325d4..bf5432b09 100644 --- a/domain/consensus/processes/pruningmanager/pruningmanager.go +++ b/domain/consensus/processes/pruningmanager/pruningmanager.go @@ -1009,7 +1009,15 @@ func (pm *pruningManager) ExpectedHeaderPruningPoint(stagingArea *model.StagingA } if hasReachabilityData { - suggestedLowHash = selectedParentHeader.PruningPoint() + // nextPruningPointAndCandidateByBlockHash needs suggestedLowHash to be in the future of the pruning point because + // otherwise reachability selected chain data is unreliable. + isInFutureOfCurrentPruningPoint, err := pm.dagTopologyManager.IsAncestorOf(stagingArea, pruningPoint, selectedParentHeader.PruningPoint()) + if err != nil { + return nil, err + } + if isInFutureOfCurrentPruningPoint { + suggestedLowHash = selectedParentHeader.PruningPoint() + } } nextOrCurrentPruningPoint, _, err = pm.nextPruningPointAndCandidateByBlockHash(stagingArea, blockHash, suggestedLowHash)