From 7facf9c1292d3783cb079a16ba797def4738e1c8 Mon Sep 17 00:00:00 2001 From: cui Date: Sun, 10 May 2026 19:03:57 +0800 Subject: [PATCH] core/txpool: use cmp.Compare instead of subtraction (#34918) This fixes a theoretical overflow condition if an account has an impossibly high nonce. --- core/txpool/locals/tx_tracker.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/txpool/locals/tx_tracker.go b/core/txpool/locals/tx_tracker.go index bb178f175e..66f3248105 100644 --- a/core/txpool/locals/tx_tracker.go +++ b/core/txpool/locals/tx_tracker.go @@ -18,6 +18,7 @@ package locals import ( + "cmp" "slices" "sync" "time" @@ -151,7 +152,7 @@ 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()) + return cmp.Compare(a.Nonce(), b.Nonce()) }) } // Rejournal the tracker while holding the lock. No new transactions will