From 1f69107650d3b74055cb600107cd940c0412ef96 Mon Sep 17 00:00:00 2001 From: welkin22 <136572398+welkin22@users.noreply.github.com> Date: Fri, 5 Jan 2024 10:28:41 +0800 Subject: [PATCH] fix: bubbling up the error when DeriveField() fails (#18) Co-authored-by: Welkin --- core/blockchain.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/blockchain.go b/core/blockchain.go index 9808e48b8a..ed2e451979 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1874,11 +1874,14 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool) proctime := time.Since(start) // processing + validation // pre-cache the block and receipts, so that it can be retrieved quickly by rcp - bc.CacheBlock(block.Hash(), block) err = types.Receipts(receipts).DeriveFields(bc.chainConfig, block.Hash(), block.NumberU64(), block.Time(), block.BaseFee(), block.Transactions()) if err != nil { log.Warn("Failed to derive receipt fields", "block", block.Hash(), "err", err) + bc.reportBlock(block, receipts, err) + close(interruptCh) + return it.index, err } + bc.CacheBlock(block.Hash(), block) bc.CacheReceipts(block.Hash(), receipts) // Update the metrics touched during block processing and validation