4040 DefaultMaxPrice = big .NewInt (500 * params .GWei )
4141 DefaultIgnorePrice = big .NewInt (1 * params .Wei )
4242 DefaultBasePrice = big .NewInt (0 )
43+ // DefaultGasTipCap is set to 100 wei instead of 1 wei for the following reasons:
44+ // 1. Very low tip values (e.g. 1 wei) can cause issues because transaction pools often reject replacing transactions
45+ // with the same gas tip cap. This becomes problematic when low tips like 1 wei fail to increase due to rounding
46+ // in some SDK implementations (e.g. 1 wei * 1.5 = 1 wei).
47+ // 2. The cost of a gas tip cap of 100 wei is negligible compared to the base fee in most cases.
48+ DefaultGasTipCap = big .NewInt (100 ) // Default minimum gas tip cap in wei (used after Curie/EIP-1559).
4349)
4450
4551type Config struct {
@@ -52,6 +58,7 @@ type Config struct {
5258 IgnorePrice * big.Int `toml:",omitempty"`
5359 CongestedThreshold int // Number of pending transactions to consider the network congested and suggest a minimum tip cap.
5460 DefaultBasePrice * big.Int `toml:",omitempty"` // Base price to set when CongestedThreshold is reached before Curie (EIP 1559).
61+ DefaultGasTipCap * big.Int `toml:",omitempty"` // Default minimum gas tip cap to use after Curie (EIP 1559).
5562}
5663
5764// OracleBackend includes all necessary background APIs for oracle.
@@ -82,6 +89,7 @@ type Oracle struct {
8289 maxHeaderHistory , maxBlockHistory int
8390 congestedThreshold int // Number of pending transactions to consider the network congested and suggest a minimum tip cap.
8491 defaultBasePrice * big.Int // Base price to set when CongestedThreshold is reached before Curie (EIP 1559).
92+ defaultGasTipCap * big.Int // Default gas tip cap to suggest after Curie (EIP 1559) when the network is not congested.
8593 historyCache * lru.Cache
8694}
8795
@@ -133,6 +141,11 @@ func NewOracle(backend OracleBackend, params Config) *Oracle {
133141 defaultBasePrice = DefaultBasePrice
134142 log .Warn ("Sanitizing invalid gasprice oracle default base price" , "provided" , params .DefaultBasePrice , "updated" , defaultBasePrice )
135143 }
144+ defaultGasTipCap := params .DefaultGasTipCap
145+ if defaultGasTipCap == nil || defaultGasTipCap .Int64 () <= 0 {
146+ defaultGasTipCap = DefaultGasTipCap
147+ log .Warn ("Sanitizing invalid gasprice oracle default gas tip cap" , "provided" , params .DefaultGasTipCap , "updated" , DefaultGasTipCap )
148+ }
136149
137150 cache , _ := lru .New (2048 )
138151 headEvent := make (chan core.ChainHeadEvent , 1 )
@@ -158,6 +171,7 @@ func NewOracle(backend OracleBackend, params Config) *Oracle {
158171 maxBlockHistory : maxBlockHistory ,
159172 congestedThreshold : congestedThreshold ,
160173 defaultBasePrice : defaultBasePrice ,
174+ defaultGasTipCap : defaultGasTipCap ,
161175 historyCache : cache ,
162176 }
163177}
@@ -195,13 +209,9 @@ func (oracle *Oracle) SuggestTipCap(ctx context.Context) (*big.Int, error) {
195209 // high-priced txs are causing the suggested tip cap to be high.
196210 pendingTxCount , _ := oracle .backend .StatsWithMinBaseFee (head .BaseFee )
197211 if pendingTxCount < oracle .congestedThreshold {
198- // Before Curie (EIP-1559), we need to return the total suggested gas price. After Curie we return 2 wei as the tip cap,
212+ // Before Curie (EIP-1559), we need to return the total suggested gas price. After Curie we return defaultGasTipCap wei as the tip cap,
199213 // as the base fee is set separately or added manually for legacy transactions.
200- // 1. Set price to at least 1 as otherwise tx with a 0 tip might be filtered out by the default mempool config.
201- // 2. Since oracle.ignoreprice was set to 2 (DefaultIgnorePrice) before by default, we need to set the price
202- // to 2 to avoid filtering in oracle.getBlockValues() by nodes that did not yet update to this version.
203- // In the future we can set the price to 1 wei.
204- price := big .NewInt (2 )
214+ price := oracle .defaultGasTipCap
205215 if ! oracle .backend .ChainConfig ().IsCurie (head .Number ) {
206216 price = oracle .defaultBasePrice
207217 }
0 commit comments