Skip to content

Commit 65baaaa

Browse files
committed
core: cache tx signature before obtaining lock (ethereum#19351)
1 parent c5b22fb commit 65baaaa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/tx_pool.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,9 @@ func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error {
970970

971971
// addTx enqueues a single transaction into the pool if it is valid.
972972
func (pool *TxPool) addTx(tx *types.Transaction, local bool) error {
973-
tx.CacheHash()
974-
types.CacheSigner(pool.signer, tx)
973+
// Cache sender in transaction before obtaining lock (pool.signer is immutable)
974+
types.Sender(pool.signer, tx)
975+
975976
pool.mu.Lock()
976977
defer pool.mu.Unlock()
977978

@@ -990,6 +991,10 @@ func (pool *TxPool) addTx(tx *types.Transaction, local bool) error {
990991

991992
// addTxs attempts to queue a batch of transactions if they are valid.
992993
func (pool *TxPool) addTxs(txs []*types.Transaction, local bool) []error {
994+
// Cache senders in transactions before obtaining lock (pool.signer is immutable)
995+
for _, tx := range txs {
996+
types.Sender(pool.signer, tx)
997+
}
993998
pool.mu.Lock()
994999
defer pool.mu.Unlock()
9951000

0 commit comments

Comments
 (0)