cs: don't panic when block is not found in store (#4163) (#4287)

Fixes #4069

Backport for v0.32.9 cherry-picked from master at ee6601a.

Co-authored-by: Greg Zaitsev <greg.zaitsev@gmail.com>
This commit is contained in:
Greg Szabo
2020-01-07 03:21:49 -05:00
committed by Jack Zampolin
parent 14e04f7606
commit d494952c82
2 changed files with 6 additions and 3 deletions

View File

@@ -20,3 +20,4 @@ program](https://hackerone.com/tendermint).
### IMPROVEMENTS:
### BUG FIXES:
- [cs] \#4069 Don't panic when block meta is not found in store (@gregzaitsev)

View File

@@ -501,10 +501,12 @@ OUTER_LOOP:
if prs.ProposalBlockParts == nil {
blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height)
if blockMeta == nil {
panic(fmt.Sprintf("Failed to load block %d when blockStore is at %d",
prs.Height, conR.conS.blockStore.Height()))
heightLogger.Error("Failed to load block meta",
"blockstoreHeight", conR.conS.blockStore.Height())
time.Sleep(conR.conS.config.PeerGossipSleepDuration)
} else {
ps.InitProposalBlockParts(blockMeta.BlockID.PartsHeader)
}
ps.InitProposalBlockParts(blockMeta.BlockID.PartsHeader)
// continue the loop since prs is a copy and not effected by this initialization
continue OUTER_LOOP
}