Skip to content

Commit d02301f

Browse files
authored
core: fix missing receipt on Clique crashes (#21045)
* core: fix missing receipt * core: address comment
1 parent 0b63915 commit d02301f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/blockchain.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,6 +1731,20 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
17311731
"uncles", len(block.Uncles()), "txs", len(block.Transactions()), "gas", block.GasUsed(),
17321732
"root", block.Root())
17331733

1734+
// Special case. Commit the empty receipt slice if we meet the known
1735+
// block in the middle. It can only happen in the clique chain. Whenever
1736+
// we insert blocks via `insertSideChain`, we only commit `td`, `header`
1737+
// and `body` if it's non-existent. Since we don't have receipts without
1738+
// reexecution, so nothing to commit. But if the sidechain will be adpoted
1739+
// as the canonical chain eventually, it needs to be reexecuted for missing
1740+
// state, but if it's this special case here(skip reexecution) we will lose
1741+
// the empty receipt entry.
1742+
if len(block.Transactions()) == 0 {
1743+
rawdb.WriteReceipts(bc.db, block.Hash(), block.NumberU64(), nil)
1744+
} else {
1745+
log.Error("Please file an issue, skip known block execution without receipt",
1746+
"hash", block.Hash(), "number", block.NumberU64())
1747+
}
17341748
if err := bc.writeKnownBlock(block); err != nil {
17351749
return it.index, err
17361750
}

0 commit comments

Comments
 (0)