@@ -490,11 +490,7 @@ func (t *BatchTxPool) processPooledTransactions(ctx context.Context) {
490490 // In case of any submission errors, add the transactions back
491491 // to the pool as a retry mechanism. This is an important part
492492 // to avoid gaps, which would require users to resubmit.
493- // Rollback the nonce range reservation from before — but only
494- // if a concurrent Add() has not already advanced past it via
495- // the fast path, otherwise we'd erase legitimate activity.
496- eoaQueue , ok := t .eoaEnqueueTxs (address , batch .txs )
497- if ! ok {
493+ if ! t .eoaEnqueueTxs (address , batch ) {
498494 t .logger .Warn ().Err (err ).Msgf (
499495 "max number of retries reached for EOA: %s, batch count: %d, nonce: %d, tx hash: %s" ,
500496 address .Hex (),
@@ -504,10 +500,6 @@ func (t *BatchTxPool) processPooledTransactions(ctx context.Context) {
504500 )
505501 t .collector .TransactionsDropped (len (batch .txs ))
506502 }
507- if eoaQueue .lastSubmittedNonce == batch .txs [len (batch .txs )- 1 ].nonce {
508- eoaQueue .lastSubmittedNonce = batch .lastSubmittedNonce
509- eoaQueue .lastSubmittedAt = batch .lastSubmittedAt
510- }
511503 } else {
512504 // Merge the ack with any concurrent Add() fast-path that
513505 // advanced the queue while we were off-lock: never regress
@@ -622,29 +614,41 @@ func (t *BatchTxPool) eoaQueueEntry(address gethCommon.Address) *txQueue {
622614}
623615
624616// eoaEnqueueTxs re-adds the given transactions to the corresponding txQueue
625- // for the given address (used as a rollback path on submission failure), and
626- // returns the txQueue. One will be created if it doesn't yet exist. A same-
627- // nonce entry already in the queue is preserved: a concurrent Add() may have
628- // dropped a fresher payload there while we were off-lock, and last-write-wins
629- // for the client means the fresh payload must win over the failed batch.
617+ // for the given address (used as a rollback path on submission failure).
618+ // One will be created if it doesn't yet exist. A same-nonce entry already
619+ // in the queue is preserved: a concurrent Add() may have dropped a fresher
620+ // payload there while we were off-lock, and last-write-wins for the client
621+ // means the fresh payload must win over the failed batch.
630622// Up to `maxSubmissionRetries` are allowed and a boolean value is returned to
631623// denote enqueue success.
632624func (t * BatchTxPool ) eoaEnqueueTxs (
633625 address gethCommon.Address ,
634- txs [] pooledEvmTx ,
635- ) ( * txQueue , bool ) {
626+ batch batchSubmission ,
627+ ) bool {
636628 queue := t .eoaQueueEntry (address )
629+ // Rollback the nonce range reservation from before — but only
630+ // if a concurrent Add() has not already advanced past it via
631+ // the fast path, otherwise we'd erase legitimate activity.
632+ if queue .lastSubmittedNonce == batch .txs [len (batch .txs )- 1 ].nonce {
633+ queue .lastSubmittedNonce = batch .lastSubmittedNonce
634+ queue .lastSubmittedAt = batch .lastSubmittedAt
635+ }
636+
637637 if queue .retries >= maxSubmissionRetries {
638- return queue , false
638+ return false
639639 }
640- for _ , tx := range txs {
640+
641+ // re-add the transactions from the batch, in the per-EOA pool
642+ for _ , tx := range batch .txs {
641643 if _ , exists := queue .txs [tx .nonce ]; exists {
642644 continue
643645 }
644646 queue .txs [tx .nonce ] = tx
645647 }
648+
649+ // increment the counter of submission retries
646650 queue .retries += 1
647- return queue , true
651+ return true
648652}
649653
650654// logSubmission records the fate of a submitted batch so a transaction is
0 commit comments