core/txpool/blobpool: defer underpriced delete out of SetGasTip

This commit is contained in:
agwab 2026-04-27 00:04:28 +09:00
parent 4343e586d0
commit a5f41e51af
2 changed files with 28 additions and 7 deletions

View file

@ -1165,8 +1165,9 @@ func (p *BlobPool) reinject(addr common.Address, txhash common.Hash) error {
// SetGasTip implements txpool.SubPool, allowing the blob pool's gas requirements // SetGasTip implements txpool.SubPool, allowing the blob pool's gas requirements
// to be kept in sync with the main transaction pool's gas requirements. // to be kept in sync with the main transaction pool's gas requirements.
func (p *BlobPool) SetGasTip(tip *big.Int) { func (p *BlobPool) SetGasTip(tip *big.Int) {
var dropped []uint64
p.lock.Lock() p.lock.Lock()
defer p.lock.Unlock()
// Store the new minimum gas tip // Store the new minimum gas tip
old := p.gasTip.Load() old := p.gasTip.Load()
@ -1209,15 +1210,10 @@ func (p *BlobPool) SetGasTip(tip *big.Int) {
heap.Remove(p.evict, p.evict.index[addr]) heap.Remove(p.evict, p.evict.index[addr])
p.reserver.Release(addr) p.reserver.Release(addr)
} }
// Clear out the transactions from the data store
log.Warn("Dropping underpriced blob transaction", "from", addr, "rejected", tx.nonce, "tip", tx.execTipCap, "want", tip, "drop", nonces, "ids", ids) log.Warn("Dropping underpriced blob transaction", "from", addr, "rejected", tx.nonce, "tip", tx.execTipCap, "want", tip, "drop", nonces, "ids", ids)
dropUnderpricedMeter.Mark(int64(len(ids))) dropUnderpricedMeter.Mark(int64(len(ids)))
for _, id := range ids { dropped = append(dropped, ids...)
if err := p.store.Delete(id); err != nil {
log.Error("Failed to delete dropped transaction", "id", id, "err", err)
}
}
break break
} }
} }
@ -1225,6 +1221,14 @@ func (p *BlobPool) SetGasTip(tip *big.Int) {
} }
log.Debug("Blobpool tip threshold updated", "tip", tip) log.Debug("Blobpool tip threshold updated", "tip", tip)
pooltipGauge.Update(tip.Int64()) pooltipGauge.Update(tip.Int64())
p.lock.Unlock()
// Flush the dropped transactions to disk without holding the pool lock.
for _, id := range dropped {
if err := p.store.Delete(id); err != nil {
log.Error("Failed to delete dropped transaction", "id", id, "err", err)
}
}
p.updateStorageMetrics() p.updateStorageMetrics()
} }

View file

@ -2235,3 +2235,20 @@ func BenchmarkWriteUnderReaderLoad(b *testing.B) {
close(stop) close(stop)
wg.Wait() wg.Wait()
} }
// BenchmarkSetGasTipDrop times a SetGasTip call that drops every tx in a
// freshly populated pool of numTxs blob transactions whose tips fall below
// the new threshold.
func BenchmarkSetGasTipDrop(b *testing.B) {
const numTxs = 256
for i := 0; i < b.N; i++ {
b.StopTimer()
pool, _, _ := setupGetBenchPool(b, numTxs)
b.StartTimer()
// Any tip far above the per-tx execTipCap (10) drops everything.
pool.SetGasTip(big.NewInt(1_000_000_000))
b.StopTimer()
pool.Close()
}
}