40
40
DefaultMaxPrice = big .NewInt (500 * params .GWei )
41
41
DefaultIgnorePrice = big .NewInt (1 * params .Wei )
42
42
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).
43
49
)
44
50
45
51
type Config struct {
@@ -52,6 +58,7 @@ type Config struct {
52
58
IgnorePrice * big.Int `toml:",omitempty"`
53
59
CongestedThreshold int // Number of pending transactions to consider the network congested and suggest a minimum tip cap.
54
60
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).
55
62
}
56
63
57
64
// OracleBackend includes all necessary background APIs for oracle.
@@ -82,6 +89,7 @@ type Oracle struct {
82
89
maxHeaderHistory , maxBlockHistory int
83
90
congestedThreshold int // Number of pending transactions to consider the network congested and suggest a minimum tip cap.
84
91
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.
85
93
historyCache * lru.Cache
86
94
}
87
95
@@ -133,6 +141,11 @@ func NewOracle(backend OracleBackend, params Config) *Oracle {
133
141
defaultBasePrice = DefaultBasePrice
134
142
log .Warn ("Sanitizing invalid gasprice oracle default base price" , "provided" , params .DefaultBasePrice , "updated" , defaultBasePrice )
135
143
}
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
+ }
136
149
137
150
cache , _ := lru .New (2048 )
138
151
headEvent := make (chan core.ChainHeadEvent , 1 )
@@ -158,6 +171,7 @@ func NewOracle(backend OracleBackend, params Config) *Oracle {
158
171
maxBlockHistory : maxBlockHistory ,
159
172
congestedThreshold : congestedThreshold ,
160
173
defaultBasePrice : defaultBasePrice ,
174
+ defaultGasTipCap : defaultGasTipCap ,
161
175
historyCache : cache ,
162
176
}
163
177
}
@@ -195,13 +209,9 @@ func (oracle *Oracle) SuggestTipCap(ctx context.Context) (*big.Int, error) {
195
209
// high-priced txs are causing the suggested tip cap to be high.
196
210
pendingTxCount , _ := oracle .backend .StatsWithMinBaseFee (head .BaseFee )
197
211
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,
199
213
// 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
205
215
if ! oracle .backend .ChainConfig ().IsCurie (head .Number ) {
206
216
price = oracle .defaultBasePrice
207
217
}
0 commit comments