From 7e0fb355e0b04d628d95b1a8e88fe0a3d195002c Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Tue, 3 Mar 2026 12:38:08 -0600 Subject: [PATCH] miner: close the state prefetcher at avoid thread leaks --- miner/worker.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/miner/worker.go b/miner/worker.go index 1f3a3a63bf..e924ca9c86 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -78,6 +78,11 @@ func (env *environment) txFitsSize(tx *types.Transaction) bool { return env.size+tx.Size() < params.MaxBlockSize-maxBlockSizeBufferZone } +// discard terminates the background threads before discarding it. +func (env *environment) discard() { + env.state.StopPrefetcher() +} + const ( commitInterruptNone int32 = iota commitInterruptNewHead @@ -125,6 +130,7 @@ func (miner *Miner) generateWork(genParam *generateParams, witness bool) *newPay if err != nil { return &newPayloadResult{err: err} } + defer work.discard() // Check withdrawals fit max block size. // Due to the cap on withdrawal count, this can actually never happen, but we still need to