From 1e7f405fc5e756ac769dce89e643acaa486ef52e Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Thu, 20 Mar 2025 21:35:26 +0800 Subject: [PATCH] core: truncate chain before the cutoff --- core/blockchain.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/blockchain.go b/core/blockchain.go index e89e02232c..b5d8ecb435 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2534,6 +2534,11 @@ func (bc *BlockChain) InsertHeadersBeforeCutoff(headers []*types.Header) (int, e if err := batch.Write(); err != nil { return 0, err } + // Truncate the useless chain segment (zero bodies and receipts) in the + // ancient store. + if _, err := bc.db.TruncateTail(last.Number.Uint64() + 1); err != nil { + return 0, err + } // Last step update all in-memory markers bc.hc.currentHeader.Store(last) bc.currentSnapBlock.Store(last)