Skip to content

Commit 72211fc

Browse files
author
Or Neeman
committed
Remove transactions without replay protection from tx pool when Donut is activated
1 parent a8cc5ef commit 72211fc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

core/tx_pool.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,20 @@ func (pool *TxPool) SetGasLimit(gasLimit uint64) {
488488
}
489489
}
490490

491+
// handleDonutActivation removes from the pool all transactions without EIP-155 replay protection
492+
func (pool *TxPool) handleDonutActivation() {
493+
toRemove := make(map[common.Hash]struct{})
494+
pool.all.Range(func(hash common.Hash, tx *types.Transaction) bool {
495+
if !tx.Protected() {
496+
toRemove[hash] = struct{}{}
497+
}
498+
return true
499+
})
500+
for hash := range toRemove {
501+
pool.removeTx(hash, false)
502+
}
503+
}
504+
491505
// Nonce returns the next nonce of an account, with all transactions executable
492506
// by the pool already applied on top.
493507
func (pool *TxPool) Nonce(addr common.Address) uint64 {
@@ -1282,7 +1296,11 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
12821296
// Update all fork indicator by next pending block number.
12831297
next := new(big.Int).Add(newHead.Number, big.NewInt(1))
12841298
pool.istanbul = pool.chainconfig.IsIstanbul(next)
1299+
wasDonut := pool.donut
12851300
pool.donut = pool.chainconfig.IsDonut(next)
1301+
if pool.donut && !wasDonut {
1302+
pool.handleDonutActivation()
1303+
}
12861304
}
12871305

12881306
// promoteExecutables moves transactions that have become processable from the

0 commit comments

Comments
 (0)