From 0099b0523a509159c9f3ba834156fec1e1ccec7a Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 6 Feb 2024 13:45:07 +0100 Subject: [PATCH] core/txpool/legacypool: fix panic in list --- core/txpool/legacypool/list.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/txpool/legacypool/list.go b/core/txpool/legacypool/list.go index 010f2dafe0..a28e09f999 100644 --- a/core/txpool/legacypool/list.go +++ b/core/txpool/legacypool/list.go @@ -326,11 +326,15 @@ func (l *list) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Transa l.subTotalCost([]*types.Transaction{old}) } // Add new tx cost to totalcost - l.totalcost.Add(l.totalcost, uint256.MustFromBig(tx.Cost())) + cost, overflow := uint256.FromBig(tx.Cost()) + if overflow { + return false, nil + } + l.totalcost.Add(l.totalcost, cost) // Otherwise overwrite the old transaction with the current one l.txs.Put(tx) - if cost := uint256.MustFromBig(tx.Cost()); l.costcap.Cmp(cost) < 0 { + if l.costcap.Cmp(cost) < 0 { l.costcap = cost } if gas := tx.Gas(); l.gascap < gas {