From 4d6c3c2dcbe9917ef77cade0be979cd16269e47d Mon Sep 17 00:00:00 2001 From: jeevan-sid Date: Thu, 25 Dec 2025 01:58:05 +0530 Subject: [PATCH] fix: delete txlookup for txns in body on rewind --- core/blockchain.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/blockchain.go b/core/blockchain.go index 858eceb630..dbc8bcfada 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1075,10 +1075,16 @@ func (bc *BlockChain) setHeadBeyondRoot(head uint64, time uint64, root common.Ha // Remove the associated body and receipts from the key-value store. // The header, hash-to-number mapping, and canonical hash will be // removed by the hc.SetHead function. + if body := rawdb.ReadBody(bc.db, hash, num); body != nil { + for _, tx := range body.Transactions { + + rawdb.DeleteTxLookupEntry(db, tx.Hash()) + } + } + rawdb.DeleteBody(db, hash, num) rawdb.DeleteReceipts(db, hash, num) } - // Todo(rjl493456442) txlookup, log index, etc } // If SetHead was only called as a chain reparation method, try to skip // touching the header chain altogether, unless the freezer is broken