From b8ee2877c5433924f78258e7e89fd74b6f97cd59 Mon Sep 17 00:00:00 2001 From: Daniel Katzan <108216499+dkatzan@users.noreply.github.com> Date: Tue, 6 Jun 2023 11:29:41 +0300 Subject: [PATCH] core/txpool: fix minor flaw in isGapped check (#27404) This fix a minor implementation issue with the newly introduced isGapped function and it is described in ticket: https://github.com/ethereum/go-ethereum/issues/27401 --- core/txpool/txpool.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index cbb8cc287..ba71dfa88 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -823,10 +823,12 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e // isGapped reports whether the given transaction is immediately executable. func (pool *TxPool) isGapped(from common.Address, tx *types.Transaction) bool { - // Short circuit if transaction matches pending nonce and can be promoted - // to pending list as an executable transaction. + // Short circuit if transaction falls within the scope of the pending list + // or matches the next pending nonce which can be promoted as an executable + // transaction afterwards. Note, the tx staleness is already checked in + // 'validateTx' function previously. next := pool.pendingNonces.get(from) - if tx.Nonce() == next { + if tx.Nonce() <= next { return false } // The transaction has a nonce gap with pending list, it's only considered