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 {
return dst.Set(tx.GasFeeCap.ToBig())
}
tip := dst.Sub(tx.GasFeeCap.ToBig(), baseFee)
if tip.Cmp(tx.GasTipCap.ToBig()) > 0 {
tip.Set(tx.GasTipCap.ToBig())
effectiveGasPrice := dst.Add(tx.GasTipCap.ToBig(), baseFee)
gasFeeCap := tx.GasFeeCap.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) {

View file

@ -101,11 +101,11 @@ func (tx *DynamicFeeTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.I
if baseFee == nil {
return dst.Set(tx.GasFeeCap)
}
tip := dst.Sub(tx.GasFeeCap, baseFee)
if tip.Cmp(tx.GasTipCap) > 0 {
tip.Set(tx.GasTipCap)
effectiveGasPrice := dst.Add(tx.GasTipCap, baseFee)
if effectiveGasPrice.Cmp(tx.GasFeeCap) > 0 {
effectiveGasPrice.Set(tx.GasFeeCap)
}
return tip.Add(tip, baseFee)
return effectiveGasPrice
}
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 {
return dst.Set(tx.GasFeeCap.ToBig())
}
tip := dst.Sub(tx.GasFeeCap.ToBig(), baseFee)
if tip.Cmp(tx.GasTipCap.ToBig()) > 0 {
tip.Set(tx.GasTipCap.ToBig())
effectiveGasPrice := dst.Add(tx.GasTipCap.ToBig(), baseFee)
gasTipCap := tx.GasFeeCap.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) {