Skip to content

Commit

Permalink
fix(dot/sync): add nil header checks (ChainSafe#2099)
Browse files Browse the repository at this point in the history
  • Loading branch information
noot committed Dec 3, 2021
1 parent fe1dade commit a7d4be0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dot/sync/chain_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,19 @@ func handleReadyBlock(bd *types.BlockData, pendingBlocks DisjointBlockSet, ready
// if we're expecting headers, validate should ensure we have a header
if bd.Header == nil {
block := pendingBlocks.getBlock(bd.Hash)
if block == nil {
logger.Criticalf("block with unknown header is ready: hash=%s", bd.Hash)
return
}

bd.Header = block.header
}

if bd.Header == nil {
logger.Criticalf("new ready block number (unknown) with hash %s", bd.Hash)
return
}

logger.Tracef("new ready block number %s with hash %s", bd.Header.Number, bd.Hash)

ready := []*types.BlockData{bd}
Expand Down

0 comments on commit a7d4be0

Please sign in to comment.