Skip to content

Commit

Permalink
RPCDaemon: eth_gasPrice add baseFee if any to suggested gas price (#2484
Browse files Browse the repository at this point in the history
)

* Avoid decreasing gasFeeCap at each GetEffectiveGasTip call
Add baseFee if any to suggested gas price

* Move add before GPO caching
  • Loading branch information
canepat authored Aug 3, 2021
1 parent dc30b02 commit 38a31ce
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/types/dynamic_fee_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (tx DynamicFeeTransaction) GetEffectiveGasTip(baseFee *uint256.Int) *uint25
if gasFeeCap.Lt(baseFee) {
return uint256.NewInt(0)
}
effectiveFee := gasFeeCap.Sub(gasFeeCap, baseFee)
effectiveFee := new(uint256.Int).Sub(gasFeeCap, baseFee)
if tx.GetTip().Lt(effectiveFee) {
return tx.GetTip()
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/types/legacy_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (tx LegacyTx) GetEffectiveGasTip(baseFee *uint256.Int) *uint256.Int {
if gasFeeCap.Lt(baseFee) {
return uint256.NewInt(0)
}
effectiveFee := gasFeeCap.Sub(gasFeeCap, baseFee)
effectiveFee := new(uint256.Int).Sub(gasFeeCap, baseFee)
if tx.GetTip().Lt(effectiveFee) {
return tx.GetTip()
} else {
Expand Down
3 changes: 3 additions & 0 deletions eth/gasprice/gasprice.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ func (gpo *Oracle) SuggestPrice(ctx context.Context) (*big.Int, error) {
if price.Cmp(gpo.maxPrice) > 0 {
price = new(big.Int).Set(gpo.maxPrice)
}
if head.BaseFee != nil {
price.Add(price, head.BaseFee)
}
gpo.cacheLock.Lock()
gpo.lastHead = headHash
gpo.lastPrice = price
Expand Down

0 comments on commit 38a31ce

Please sign in to comment.