mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-10 06:28:04 -05:00
feat(sender): add min gas tip (#1331)
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
var tag = "v4.4.4"
|
||||
var tag = "v4.4.5"
|
||||
|
||||
var commit = func() string {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"escalate_multiple_den": 1,
|
||||
"max_gas_price": 1000000000000,
|
||||
"tx_type": "LegacyTx",
|
||||
"check_pending_time": 1
|
||||
"check_pending_time": 1,
|
||||
"min_gas_tip": 100000000
|
||||
},
|
||||
"gas_oracle_config": {
|
||||
"min_gas_price": 0,
|
||||
@@ -42,7 +43,8 @@
|
||||
"max_gas_price": 1000000000000,
|
||||
"max_blob_gas_price": 10000000000000,
|
||||
"tx_type": "DynamicFeeTx",
|
||||
"check_pending_time": 1
|
||||
"check_pending_time": 1,
|
||||
"min_gas_tip": 100000000
|
||||
},
|
||||
"gas_oracle_config": {
|
||||
"min_gas_price": 0,
|
||||
|
||||
@@ -26,6 +26,8 @@ type SenderConfig struct {
|
||||
EscalateMultipleDen uint64 `json:"escalate_multiple_den"`
|
||||
// The maximum gas price can be used to send transaction.
|
||||
MaxGasPrice uint64 `json:"max_gas_price"`
|
||||
// The minimum gas tip can be used to send transaction.
|
||||
MinGasTip uint64 `json:"min_gas_tip"`
|
||||
// The maximum blob gas price can be used to send transaction.
|
||||
MaxBlobGasPrice uint64 `json:"max_blob_gas_price"`
|
||||
// The transaction type to use: LegacyTx, DynamicFeeTx, BlobTx
|
||||
|
||||
@@ -17,6 +17,12 @@ func (s *Sender) estimateLegacyGas(to *common.Address, data []byte, fallbackGasL
|
||||
log.Error("estimateLegacyGas SuggestGasPrice failure", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
minGasTip := new(big.Int).SetUint64(s.config.MinGasTip)
|
||||
if gasPrice.Cmp(minGasTip) < 0 {
|
||||
gasPrice = minGasTip
|
||||
}
|
||||
|
||||
gasLimit, _, err := s.estimateGasLimit(to, data, nil, gasPrice, nil, nil, nil)
|
||||
if err != nil {
|
||||
log.Error("estimateLegacyGas estimateGasLimit failure", "gas price", gasPrice, "from", s.auth.From.String(),
|
||||
@@ -41,6 +47,11 @@ func (s *Sender) estimateDynamicGas(to *common.Address, data []byte, baseFee uin
|
||||
return nil, err
|
||||
}
|
||||
|
||||
minGasTip := new(big.Int).SetUint64(s.config.MinGasTip)
|
||||
if gasTipCap.Cmp(minGasTip) < 0 {
|
||||
gasTipCap = minGasTip
|
||||
}
|
||||
|
||||
gasFeeCap := getGasFeeCap(new(big.Int).SetUint64(baseFee), gasTipCap)
|
||||
gasLimit, accessList, err := s.estimateGasLimit(to, data, nil, nil, gasTipCap, gasFeeCap, nil)
|
||||
if err != nil {
|
||||
@@ -72,6 +83,11 @@ func (s *Sender) estimateBlobGas(to *common.Address, data []byte, sidecar *gethT
|
||||
return nil, err
|
||||
}
|
||||
|
||||
minGasTip := new(big.Int).SetUint64(s.config.MinGasTip)
|
||||
if gasTipCap.Cmp(minGasTip) < 0 {
|
||||
gasTipCap = minGasTip
|
||||
}
|
||||
|
||||
gasFeeCap := getGasFeeCap(new(big.Int).SetUint64(baseFee), gasTipCap)
|
||||
blobGasFeeCap := getBlobGasFeeCap(new(big.Int).SetUint64(blobBaseFee))
|
||||
gasLimit, accessList, err := s.estimateGasLimit(to, data, sidecar, nil, gasTipCap, gasFeeCap, blobGasFeeCap)
|
||||
|
||||
Reference in New Issue
Block a user