Use nil suggestedLowHash if selected parent pruning point is not in the future of the current one (#1972)

Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
This commit is contained in:
Ori Newman 2022-03-13 17:22:03 +02:00 committed by GitHub
parent c81506220b
commit 7a95f0c7a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)