Skip to content

Commit

Permalink
Fix tx replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonponti committed Nov 26, 2024
1 parent cb9442b commit 897939b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/exchange/rates.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func getRate(exchangeRates common.ExchangeRates, feeCurrency *common.Address) (*
// returns -1 0 or 1 depending if val1 < val2, val1 == val2, or val1 > val2 respectively.
func CompareValue(exchangeRates common.ExchangeRates, val1 *big.Int, feeCurrency1 *common.Address, val2 *big.Int, feeCurrency2 *common.Address) (int, error) {
// Short circuit if the fee currency is the same.
if feeCurrency1 == feeCurrency2 {
if common.AreSameAddress(feeCurrency1, feeCurrency2) {
return val1.Cmp(val2), nil
}

Expand Down
8 changes: 6 additions & 2 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,11 @@ func (pool *LegacyPool) validateTx(tx *types.Transaction, local bool) error {
},
ExistingExpenditure: func(addr common.Address) (*big.Int, *big.Int) {
if list := pool.pending[addr]; list != nil {
return list.TotalCostFor(tx.FeeCurrency()).ToBig(), list.TotalCostFor(nil).ToBig()
if tx.FeeCurrency() != nil {
return list.TotalCostFor(tx.FeeCurrency()).ToBig(), list.TotalCostFor(nil).ToBig()
} else {
return common.Big0, list.TotalCostFor(nil).ToBig()
}
}
return new(big.Int), new(big.Int)
},
Expand All @@ -703,7 +707,7 @@ func (pool *LegacyPool) validateTx(tx *types.Transaction, local bool) error {
nativeCost = nativeCost.Add(nativeCost, l1Cost)
}
}
if tx.FeeCurrency() != feeCurrency {
if !common.AreSameAddress(tx.FeeCurrency(), feeCurrency) {
// We are only interested in costs in the same currency
feeCurrencyCost = new(big.Int)
}
Expand Down

0 comments on commit 897939b

Please sign in to comment.