Skip to content

Commit

Permalink
bugfix: guard against the async state update if poem fails
Browse files Browse the repository at this point in the history
If state generation takes a long, time, we cannot lower the pending
header that is stored on best ph key
  • Loading branch information
gameofpointers committed Sep 1, 2023
1 parent de2d12f commit bd804c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,9 @@ func (sl *Slice) updatePhCacheFromDom(pendingHeader types.PendingHeader, termini
}
}

sl.phCacheMu.Lock()
sl.updatePhCache(types.NewPendingHeader(combinedPendingHeader, localPendingHeader.Termini()), false, nil, subReorg)
sl.phCacheMu.Unlock()

return nil
}
Expand All @@ -795,6 +797,14 @@ func (sl *Slice) updatePhCache(pendingHeaderWithTermini types.PendingHeader, inS
if exists {
pendingHeaderWithTermini.SetHeader(sl.combinePendingHeader(localHeader, pendingHeaderWithTermini.Header(), common.ZONE_CTX, true))
}

bestPh, exists := sl.readPhCache(sl.bestPhKey)
if !exists {
return
}
if !sl.poem(pendingHeaderWithTermini.Header().ParentEntropy(), bestPh.Header().ParentEntropy()) {
return
}
}

// Update the pendingHeader Cache
Expand Down

0 comments on commit bd804c1

Please sign in to comment.