Skip to content

Commit

Permalink
core: fix missing receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinod Damle committed Jan 22, 2021
1 parent 8d128e8 commit 06c383f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,20 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
"uncles", len(block.Uncles()), "txs", len(block.Transactions()), "gas", block.GasUsed(),
"root", block.Root())

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

0 comments on commit 06c383f

Please sign in to comment.