core: fix cached receipts format

This commit is contained in:
zsfelfoldi 2025-09-30 18:33:31 +02:00
parent 6411f1e0ff
commit 0c5200bb43

View file

@ -1619,6 +1619,17 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
bc.blockCache.Add(blockHash, block)
rawdb.WriteReceipts(blockBatch, blockHash, block.NumberU64(), receipts)
if receipts != nil {
// ensure that receipts are cached in the exact same format as when reconstructed from database.
for _, receipt := range receipts {
if receipt.Logs == nil {
receipt.Logs = []*types.Log{}
}
}
var blobGasPrice *big.Int
if block.ExcessBlobGas() != nil {
blobGasPrice = eip4844.CalcBlobFee(bc.chainConfig, block.Header())
}
types.Receipts(receipts).DeriveFields(bc.chainConfig, blockHash, block.NumberU64(), block.Time(), block.BaseFee(), blobGasPrice, block.Transactions())
bc.receiptsCache.Add(blockHash, receipts)
} else {
bc.receiptsCache.Add(blockHash, []*types.Receipt{})