-
Notifications
You must be signed in to change notification settings - Fork 21.5k
core/txpool: add sanity overflow check #32544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rjl493456442
merged 3 commits into
ethereum:master
from
MariusVanDerWijden:add-overflow-checks
Sep 10, 2025
Merged
core/txpool: add sanity overflow check #32544
rjl493456442
merged 3 commits into
ethereum:master
from
MariusVanDerWijden:add-overflow-checks
Sep 10, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lightclient
previously approved these changes
Sep 4, 2025
Member
diff --git a/core/txpool/legacypool/list.go b/core/txpool/legacypool/list.go
index e5c48d538d..85008e3310 100644
--- a/core/txpool/legacypool/list.go
+++ b/core/txpool/legacypool/list.go
@@ -323,8 +323,6 @@ 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())
@@ -337,6 +335,10 @@ func (l *list) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Transa
}
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)
if l.costcap.Cmp(cost) < 0 { |
Member
Author
|
PTAL @rjl493456442 |
core/txpool/legacypool/list.go
Outdated
| l.totalcost = total | ||
|
|
||
| // Old is being replaced, subtract old cost | ||
| l.subTotalCost([]*types.Transaction{old}) |
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old can be nil. l.subTotalCost([]*types.Transaction{nil}) will panic, isn't it?
Member
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes good catch
rjl493456442
approved these changes
Sep 10, 2025
Sahil-4555
pushed a commit
to Sahil-4555/go-ethereum
that referenced
this pull request
Oct 12, 2025
Adds a sanity check in the transaction pool Co-authored-by @rjl493456442
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a sanity check in the transaction pool
Co-authored-by @rjl493456442