Skip to content

Commit 0c5200b

Browse files
committed
core: fix cached receipts format
1 parent 6411f1e commit 0c5200b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

core/blockchain.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,17 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
16191619
bc.blockCache.Add(blockHash, block)
16201620
rawdb.WriteReceipts(blockBatch, blockHash, block.NumberU64(), receipts)
16211621
if receipts != nil {
1622+
// ensure that receipts are cached in the exact same format as when reconstructed from database.
1623+
for _, receipt := range receipts {
1624+
if receipt.Logs == nil {
1625+
receipt.Logs = []*types.Log{}
1626+
}
1627+
}
1628+
var blobGasPrice *big.Int
1629+
if block.ExcessBlobGas() != nil {
1630+
blobGasPrice = eip4844.CalcBlobFee(bc.chainConfig, block.Header())
1631+
}
1632+
types.Receipts(receipts).DeriveFields(bc.chainConfig, blockHash, block.NumberU64(), block.Time(), block.BaseFee(), blobGasPrice, block.Transactions())
16221633
bc.receiptsCache.Add(blockHash, receipts)
16231634
} else {
16241635
bc.receiptsCache.Add(blockHash, []*types.Receipt{})

0 commit comments

Comments
 (0)