Skip to content

config: apply default value for Eth.Miner option in config.toml#3022

Merged
zzzckck merged 1 commit intobnb-chain:developfrom
zzzckck:config_default_value_gen
Apr 14, 2025
Merged

config: apply default value for Eth.Miner option in config.toml#3022
zzzckck merged 1 commit intobnb-chain:developfrom
zzzckck:config_default_value_gen

Conversation

@zzzckck
Copy link
Collaborator

@zzzckck zzzckck commented Apr 14, 2025

Description

To simplify the configuration of config.toml file, node operators can just leave some options empty if they just want the default value.
For more background, pls refer: #2986

miner/minerconfig/gen_config.go
miner/minerconfig/gen_mevconfig.go

The above 2 new files are generated by:

cd $<bsc>
go generate ./...

Rationale

R1: Why use pointer instead of zero value check
Generally, pointer value is preferable to avoid initialising unset variable. It will be nil pointer, instead of a zero-value.
Sometime we just can't tell if the zero-value decoded from the TOML file was set by user specifically or not.
For example, Alice sets the "maxPoolSize" to "0" in config.toml to disable the pool, it's better not to be taken as Alice want the default value.

Example

a.Current Problem

case 1: DelayLeftOver of [Eth.Miner] in config.toml
DelayLeftOver has default value of 50000000, before the PR, it has to be configured specifically, like:

[Eth.Miner]
GasCeil = 140000000
DelayLeftOver=50000000

If user creates the [Eth.Miner], without DelayLeftOver, like:

[Eth.Miner]
GasCeil = 140000000

then DelayLeftOver will be set to 0, which is unexpected.

case 2: NoInterruptLeftOver of [Eth.Miner.Mev] in config.toml
NoInterruptLeftOver has the default value of 400000000, before the PR, it has to be configured specifically, like:

[Eth.Miner.Mev]
Enabled = true
NoInterruptLeftOver = 400000000

If user creates the [Eth.Miner.Mev], without DelayLeftOver, like:

[Eth.Miner.Mev]
Enabled = true

then NoInterruptLeftOver will be set to 0, which is unexpected.

b.After this PR

[Eth.Miner]
GasCeil = 140000000
[Eth.Miner.Mev]
Enabled = true

DelayLeftOver and NoInterruptLeftOver can be skipped and they will have the default value respectively.

Changes

NA

@zzzckck zzzckck merged commit 84feb02 into bnb-chain:develop Apr 14, 2025
7 checks passed
@zzzckck zzzckck deleted the config_default_value_gen branch April 14, 2025 08:53
zzzckck added a commit to zzzckck/bsc that referenced this pull request Apr 14, 2025
zzzckck added a commit that referenced this pull request Apr 14, 2025
forcodedancing pushed a commit to forcodedancing/bsc that referenced this pull request Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments