core/types: improve effectiveGasPrice

This commit is contained in:
cuiweixie 2026-01-24 10:19:50 +08:00
parent 9a8e14e77e
commit ba80c16384
3 changed files with 14 additions and 12 deletions

View file

@ -295,11 +295,12 @@ func (tx *BlobTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.Int {
if baseFee == nil { if baseFee == nil {
return dst.Set(tx.GasFeeCap.ToBig()) return dst.Set(tx.GasFeeCap.ToBig())
} }
tip := dst.Sub(tx.GasFeeCap.ToBig(), baseFee) effectiveGasPrice := dst.Add(tx.GasTipCap.ToBig(), baseFee)
if tip.Cmp(tx.GasTipCap.ToBig()) > 0 { gasFeeCap := tx.GasFeeCap.ToBig()
tip.Set(tx.GasTipCap.ToBig()) if effectiveGasPrice.Cmp(gasFeeCap) > 0 {
effectiveGasPrice.Set(gasFeeCap)
} }
return tip.Add(tip, baseFee) return effectiveGasPrice
} }
func (tx *BlobTx) rawSignatureValues() (v, r, s *big.Int) { func (tx *BlobTx) rawSignatureValues() (v, r, s *big.Int) {

View file

@ -101,11 +101,11 @@ func (tx *DynamicFeeTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.I
if baseFee == nil { if baseFee == nil {
return dst.Set(tx.GasFeeCap) return dst.Set(tx.GasFeeCap)
} }
tip := dst.Sub(tx.GasFeeCap, baseFee) effectiveGasPrice := dst.Add(tx.GasTipCap, baseFee)
if tip.Cmp(tx.GasTipCap) > 0 { if effectiveGasPrice.Cmp(tx.GasFeeCap) > 0 {
tip.Set(tx.GasTipCap) effectiveGasPrice.Set(tx.GasFeeCap)
} }
return tip.Add(tip, baseFee) return effectiveGasPrice
} }
func (tx *DynamicFeeTx) rawSignatureValues() (v, r, s *big.Int) { func (tx *DynamicFeeTx) rawSignatureValues() (v, r, s *big.Int) {

View file

@ -202,11 +202,12 @@ func (tx *SetCodeTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.Int
if baseFee == nil { if baseFee == nil {
return dst.Set(tx.GasFeeCap.ToBig()) return dst.Set(tx.GasFeeCap.ToBig())
} }
tip := dst.Sub(tx.GasFeeCap.ToBig(), baseFee) effectiveGasPrice := dst.Add(tx.GasTipCap.ToBig(), baseFee)
if tip.Cmp(tx.GasTipCap.ToBig()) > 0 { gasTipCap := tx.GasFeeCap.ToBig()
tip.Set(tx.GasTipCap.ToBig()) if effectiveGasPrice.Cmp(gasTipCap) > 0 {
effectiveGasPrice.Set(gasTipCap)
} }
return tip.Add(tip, baseFee) return effectiveGasPrice
} }
func (tx *SetCodeTx) rawSignatureValues() (v, r, s *big.Int) { func (tx *SetCodeTx) rawSignatureValues() (v, r, s *big.Int) {