Skip to content
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

fix(list-totalcost): Add l1Cost instead of transaction cost #324

Open
wants to merge 1 commit into
base: optimism
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/txpool/legacypool/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ func (l *list) Add(tx *types.Transaction, priceBump uint64, l1CostFn txpool.L1Co
l.totalcost.Add(l.totalcost, cost)
if l1CostFn != nil {
if l1Cost := l1CostFn(tx.RollupCostData()); l1Cost != nil { // add rollup cost
cost, overflow := uint256.FromBig(l1Cost)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be modifying line 351 to be l.totalcost.Add(l.totalcost, l1Cost) ?

Copy link
Author

@kustrun kustrun Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this doesn't work because typeOf(l1Cost) = *big.Int and typeOf(l1.totalcost) = *uint256.Int. Consequently, I referred to lines 340-344 to implement the l1Cost cast from *big.Int to *uint256.Int.

The variable cost in this fix holds the intermediate value of l1Cost as *uint256.Int, allowing it to be added to l1.totalcost on line 351.

if overflow {
return false, nil
}
l.totalcost.Add(l.totalcost, cost)
}
}
Expand Down