Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth/gasprice: remove default from config #30080

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if eth.APIBackend.allowUnprotectedTxs {
log.Info("Unprotected transactions allowed")
}
gpoParams := config.GPO
if gpoParams.Default == nil {
gpoParams.Default = config.Miner.GasPrice
}
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, config.GPO, config.Miner.GasPrice)

// Setup DNS discovery iterators.
dnsclient := dnsdisc.NewClient(dnsdisc.Config{})
Expand Down
2 changes: 1 addition & 1 deletion eth/gasprice/feehistory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestFeeHistory(t *testing.T) {
MaxBlockHistory: c.maxBlock,
}
backend := newTestBackend(t, big.NewInt(16), big.NewInt(28), c.pending)
oracle := NewOracle(backend, config)
oracle := NewOracle(backend, config, nil)
MariusVanDerWijden marked this conversation as resolved.
Show resolved Hide resolved

first, reward, baseFee, ratio, blobBaseFee, blobRatio, err := oracle.FeeHistory(context.Background(), c.count, c.last, c.percent)
backend.teardown()
Expand Down
8 changes: 5 additions & 3 deletions eth/gasprice/gasprice.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type Config struct {
Percentile int
MaxHeaderHistory uint64
MaxBlockHistory uint64
Default *big.Int `toml:",omitempty"`
MaxPrice *big.Int `toml:",omitempty"`
IgnorePrice *big.Int `toml:",omitempty"`
}
Expand Down Expand Up @@ -79,7 +78,7 @@ type Oracle struct {

// NewOracle returns a new gasprice oracle which can recommend suitable
// gasprice for newly created transaction.
func NewOracle(backend OracleBackend, params Config) *Oracle {
MariusVanDerWijden marked this conversation as resolved.
Show resolved Hide resolved
func NewOracle(backend OracleBackend, params Config, startPrice *big.Int) *Oracle {
blocks := params.Blocks
if blocks < 1 {
blocks = 1
Expand Down Expand Up @@ -115,6 +114,9 @@ func NewOracle(backend OracleBackend, params Config) *Oracle {
maxBlockHistory = 1
log.Warn("Sanitizing invalid gasprice oracle max block history", "provided", params.MaxBlockHistory, "updated", maxBlockHistory)
}
if startPrice == nil {
startPrice = new(big.Int)
}

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

return &Oracle{
backend: backend,
lastPrice: params.Default,
lastPrice: startPrice,
maxPrice: maxPrice,
ignorePrice: ignorePrice,
checkBlocks: blocks,
Expand Down
3 changes: 1 addition & 2 deletions eth/gasprice/gasprice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ func TestSuggestTipCap(t *testing.T) {
config := Config{
Blocks: 3,
Percentile: 60,
Default: big.NewInt(params.GWei),
}
var cases = []struct {
fork *big.Int // London fork number
Expand All @@ -249,7 +248,7 @@ func TestSuggestTipCap(t *testing.T) {
}
for _, c := range cases {
backend := newTestBackend(t, c.fork, nil, false)
oracle := NewOracle(backend, config)
oracle := NewOracle(backend, config, big.NewInt(params.GWei))

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