From fbae0792521c4cbbbce67cf5b23cfd01f5039283 Mon Sep 17 00:00:00 2001 From: Snezhkko Date: Wed, 26 Nov 2025 10:20:01 +0200 Subject: [PATCH] core/txpool/locals: fix unsafe nonce comparator in TxTracker.recheck journal sort --- core/txpool/locals/tx_tracker.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/txpool/locals/tx_tracker.go b/core/txpool/locals/tx_tracker.go index bb178f175e5d..603707f0d68d 100644 --- a/core/txpool/locals/tx_tracker.go +++ b/core/txpool/locals/tx_tracker.go @@ -151,7 +151,13 @@ func (tracker *TxTracker) recheck(journalCheck bool) []*types.Transaction { for _, list := range rejournal { // cmp(a, b) should return a negative number when a < b, slices.SortFunc(list, func(a, b *types.Transaction) int { - return int(a.Nonce() - b.Nonce()) + if a.Nonce() < b.Nonce() { + return -1 + } + if a.Nonce() > b.Nonce() { + return 1 + } + return 0 }) } // Rejournal the tracker while holding the lock. No new transactions will