Skip to content

Commit eb9d7d1

Browse files
authored
Merge pull request #21170 from duanhao0814/fix-dup-ecrecover
core: filter out txs with invalid signatures as soon as possible
2 parents a981b60 + 8523ad4 commit eb9d7d1

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎core/tx_pool.go‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,16 +781,22 @@ func (pool *TxPool) addTxs(txs []*types.Transaction, local, sync bool) []error {
781781
knownTxMeter.Mark(1)
782782
continue
783783
}
784+
// Exclude transactions with invalid signatures as soon as
785+
// possible and cache senders in transactions before
786+
// obtaining lock
787+
_, err := types.Sender(pool.signer, tx)
788+
if err != nil {
789+
errs[i] = ErrInvalidSender
790+
invalidTxMeter.Mark(1)
791+
continue
792+
}
784793
// Accumulate all unknown transactions for deeper processing
785794
news = append(news, tx)
786795
}
787796
if len(news) == 0 {
788797
return errs
789798
}
790-
// Cache senders in transactions before obtaining lock (pool.signer is immutable)
791-
for _, tx := range news {
792-
types.Sender(pool.signer, tx)
793-
}
799+
794800
// Process all the new transaction and merge any errors into the original slice
795801
pool.mu.Lock()
796802
newErrs, dirtyAddrs := pool.addTxsLocked(news, local)

0 commit comments

Comments
 (0)