Skip to content

Commit 0099b05

Browse files
committed
core/txpool/legacypool: fix panic in list
1 parent 9f164a6 commit 0099b05

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/txpool/legacypool/list.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,15 @@ func (l *list) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Transa
326326
l.subTotalCost([]*types.Transaction{old})
327327
}
328328
// Add new tx cost to totalcost
329-
l.totalcost.Add(l.totalcost, uint256.MustFromBig(tx.Cost()))
329+
cost, overflow := uint256.FromBig(tx.Cost())
330+
if overflow {
331+
return false, nil
332+
}
333+
l.totalcost.Add(l.totalcost, cost)
330334

331335
// Otherwise overwrite the old transaction with the current one
332336
l.txs.Put(tx)
333-
if cost := uint256.MustFromBig(tx.Cost()); l.costcap.Cmp(cost) < 0 {
337+
if l.costcap.Cmp(cost) < 0 {
334338
l.costcap = cost
335339
}
336340
if gas := tx.Gas(); l.gascap < gas {

0 commit comments

Comments
 (0)