mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
core/txpool: add sanity overflow check (#32544)
Adds a sanity check in the transaction pool Co-authored-by @rjl493456442
This commit is contained in:
parent
586ac9b334
commit
d68528cadb
1 changed files with 10 additions and 3 deletions
|
|
@ -323,15 +323,22 @@ func (l *list) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Transa
|
|||
if tx.GasFeeCapIntCmp(thresholdFeeCap) < 0 || tx.GasTipCapIntCmp(thresholdTip) < 0 {
|
||||
return false, nil
|
||||
}
|
||||
// Old is being replaced, subtract old cost
|
||||
l.subTotalCost([]*types.Transaction{old})
|
||||
}
|
||||
// Add new tx cost to totalcost
|
||||
cost, overflow := uint256.FromBig(tx.Cost())
|
||||
if overflow {
|
||||
return false, nil
|
||||
}
|
||||
l.totalcost.Add(l.totalcost, cost)
|
||||
total, overflow := new(uint256.Int).AddOverflow(l.totalcost, cost)
|
||||
if overflow {
|
||||
return false, nil
|
||||
}
|
||||
l.totalcost = total
|
||||
|
||||
// Old is being replaced, subtract old cost
|
||||
if old != nil {
|
||||
l.subTotalCost([]*types.Transaction{old})
|
||||
}
|
||||
|
||||
// Otherwise overwrite the old transaction with the current one
|
||||
l.txs.Put(tx)
|
||||
|
|
|
|||
Loading…
Reference in a new issue