Skip to content

Commit 380688c

Browse files
eth/gasprice: remove default from config (#30080)
* eth/gasprice: remove default from config * eth/gasprice: sanitize startPrice
1 parent 944718b commit 380688c

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

eth/backend.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
264264
if eth.APIBackend.allowUnprotectedTxs {
265265
log.Info("Unprotected transactions allowed")
266266
}
267-
gpoParams := config.GPO
268-
if gpoParams.Default == nil {
269-
gpoParams.Default = config.Miner.GasPrice
270-
}
271-
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
267+
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, config.GPO, config.Miner.GasPrice)
272268

273269
// Setup DNS discovery iterators.
274270
dnsclient := dnsdisc.NewClient(dnsdisc.Config{})

eth/gasprice/feehistory_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestFeeHistory(t *testing.T) {
5959
MaxBlockHistory: c.maxBlock,
6060
}
6161
backend := newTestBackend(t, big.NewInt(16), big.NewInt(28), c.pending)
62-
oracle := NewOracle(backend, config)
62+
oracle := NewOracle(backend, config, nil)
6363

6464
first, reward, baseFee, ratio, blobBaseFee, blobRatio, err := oracle.FeeHistory(context.Background(), c.count, c.last, c.percent)
6565
backend.teardown()

eth/gasprice/gasprice.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ type Config struct {
4545
Percentile int
4646
MaxHeaderHistory uint64
4747
MaxBlockHistory uint64
48-
Default *big.Int `toml:",omitempty"`
4948
MaxPrice *big.Int `toml:",omitempty"`
5049
IgnorePrice *big.Int `toml:",omitempty"`
5150
}
@@ -79,7 +78,7 @@ type Oracle struct {
7978

8079
// NewOracle returns a new gasprice oracle which can recommend suitable
8180
// gasprice for newly created transaction.
82-
func NewOracle(backend OracleBackend, params Config) *Oracle {
81+
func NewOracle(backend OracleBackend, params Config, startPrice *big.Int) *Oracle {
8382
blocks := params.Blocks
8483
if blocks < 1 {
8584
blocks = 1
@@ -115,6 +114,9 @@ func NewOracle(backend OracleBackend, params Config) *Oracle {
115114
maxBlockHistory = 1
116115
log.Warn("Sanitizing invalid gasprice oracle max block history", "provided", params.MaxBlockHistory, "updated", maxBlockHistory)
117116
}
117+
if startPrice == nil {
118+
startPrice = new(big.Int)
119+
}
118120

119121
cache := lru.NewCache[cacheKey, processedFees](2048)
120122
headEvent := make(chan core.ChainHeadEvent, 1)
@@ -131,7 +133,7 @@ func NewOracle(backend OracleBackend, params Config) *Oracle {
131133

132134
return &Oracle{
133135
backend: backend,
134-
lastPrice: params.Default,
136+
lastPrice: startPrice,
135137
maxPrice: maxPrice,
136138
ignorePrice: ignorePrice,
137139
checkBlocks: blocks,

eth/gasprice/gasprice_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ func TestSuggestTipCap(t *testing.T) {
235235
config := Config{
236236
Blocks: 3,
237237
Percentile: 60,
238-
Default: big.NewInt(params.GWei),
239238
}
240239
var cases = []struct {
241240
fork *big.Int // London fork number
@@ -249,7 +248,7 @@ func TestSuggestTipCap(t *testing.T) {
249248
}
250249
for _, c := range cases {
251250
backend := newTestBackend(t, c.fork, nil, false)
252-
oracle := NewOracle(backend, config)
251+
oracle := NewOracle(backend, config, big.NewInt(params.GWei))
253252

254253
// The gas price sampled is: 32G, 31G, 30G, 29G, 28G, 27G
255254
got, err := oracle.SuggestTipCap(context.Background())

0 commit comments

Comments
 (0)